1
0
Fork 0

Merging upstream version 1.18.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-21 11:26:24 +01:00
parent 1327a2b8ad
commit 734bd31e8b
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
45 changed files with 1576 additions and 774 deletions

View file

@ -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; }