summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'decoder.h')
-rw-r--r--decoder.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/decoder.h b/decoder.h
index 5ffc0be..8bc64bc 100644
--- a/decoder.h
+++ b/decoder.h
@@ -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; }