diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2016-05-20 06:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2016-05-20 06:55:18 +0000 |
commit | 07c2a71a11edd637f0ec9b42b5c5621980c96562 (patch) | |
tree | ffe015da89db655e2f4edbabd6924e41b3971f02 /decoder.h | |
parent | Adding debian version 1.18~pre2-1. (diff) | |
download | lziprecover-07c2a71a11edd637f0ec9b42b5c5621980c96562.tar.xz lziprecover-07c2a71a11edd637f0ec9b42b5c5621980c96562.zip |
Merging upstream version 1.18.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.h')
-rw-r--r-- | decoder.h | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -1,5 +1,5 @@ /* Lziprecover - Data recovery tool for the lzip format - Copyright (C) 2009-2015 Antonio Diaz Diaz. + Copyright (C) 2009-2016 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,14 +47,15 @@ public: ~Range_decoder() { delete[] buffer; } - bool code_is_zero() const { return ( code == 0 ); } + unsigned get_code() const { return code; } bool finished() { return pos >= stream_pos && !read_block(); } unsigned long long member_position() const { return partial_member_pos + pos; } void reset_member_position() { partial_member_pos = -pos; } uint8_t get_byte() { - if( finished() ) return 0xAA; // make code != 0 + // 0xFF avoids decoder error if member is truncated at EOS marker + if( finished() ) return 0xFF; return buffer[pos++]; } @@ -219,6 +220,7 @@ class LZ_decoder unsigned stream_pos; // first byte not yet written to file uint32_t crc_; const int outfd; // output file descriptor + bool pos_wrapped; unsigned long long stream_position() const { return partial_data_pos + stream_pos; } @@ -270,7 +272,7 @@ class LZ_decoder void operator=( const LZ_decoder & ); // declared as private public: - LZ_decoder( const File_header & header, Range_decoder & rde, const int ofd, + LZ_decoder( Range_decoder & rde, const unsigned dict_size, const int ofd, const unsigned long long oskip = 0, const unsigned long long oend = -1ULL ) : @@ -278,12 +280,13 @@ public: outend( oend ), partial_data_pos( 0 ), rdec( rde ), - dictionary_size( header.dictionary_size() ), + dictionary_size( dict_size ), buffer( new uint8_t[dictionary_size] ), pos( 0 ), stream_pos( 0 ), crc_( 0xFFFFFFFFU ), - outfd( ofd ) + outfd( ofd ), + pos_wrapped( false ) { buffer[dictionary_size-1] = 0; } // prev_byte of first byte ~LZ_decoder() { delete[] buffer; } |