summaryrefslogtreecommitdiffstats
path: root/lzip_index.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lzip_index.h (renamed from file_index.h)36
1 files changed, 20 insertions, 16 deletions
diff --git a/file_index.h b/lzip_index.h
index da374ae..d4f2ef9 100644
--- a/file_index.h
+++ b/lzip_index.h
@@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for the lzip format
- Copyright (C) 2009-2018 Antonio Diaz Diaz.
+ Copyright (C) 2009-2019 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
@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class File_index
+class Lzip_index
{
struct Member
{
@@ -30,36 +30,40 @@ class File_index
bool operator!=( const Member & m ) const { return ( mblock != m.mblock ); }
};
+ // member_vector only contains good members.
+ // Garbage between members is represented by gaps between mblocks.
std::vector< Member > member_vector;
std::string error_;
- long long isize;
+ long long insize;
int retval_;
void set_errno_error( const char * const msg );
void set_num_error( const char * const msg, unsigned long long num );
- bool skip_trailing_data( const int fd, long long & pos,
- const bool ignore_bad_ds,
- const bool ignore_trailing, const bool loose_trailing );
+ bool skip_gap( const int fd, long long & pos,
+ const bool ignore_trailing, const bool loose_trailing,
+ const bool ignore_bad_ds, const bool ignore_gaps );
public:
- File_index() : error_( "No index" ), isize( 0 ), retval_( 2 ) {}
- File_index( const int infd, const bool ignore_bad_ds,
- const bool ignore_trailing, const bool loose_trailing );
- File_index( const std::vector< int > & infd_vector, const long long fsize );
+ Lzip_index() : error_( "No index" ), insize( 0 ), retval_( 2 ) {}
+ Lzip_index( const int infd, const bool ignore_trailing,
+ const bool loose_trailing, const bool ignore_bad_ds = false,
+ const bool ignore_gaps = false, const long long max_pos = 0 );
+ Lzip_index( const std::vector< int > & infd_vector, const long long fsize );
long members() const { return member_vector.size(); }
+ long blocks( const bool count_tdata ) const; // members + gaps [+ tdata]
const std::string & error() const { return error_; }
int retval() const { return retval_; }
- bool operator==( const File_index & fi ) const
+ bool operator==( const Lzip_index & li ) const
{
- if( retval_ || fi.retval_ || isize != fi.isize ||
- member_vector.size() != fi.member_vector.size() ) return false;
+ if( retval_ || li.retval_ || insize != li.insize ||
+ member_vector.size() != li.member_vector.size() ) return false;
for( unsigned long i = 0; i < member_vector.size(); ++i )
- if( member_vector[i] != fi.member_vector[i] ) return false;
+ if( member_vector[i] != li.member_vector[i] ) return false;
return true;
}
- bool operator!=( const File_index & fi ) const { return !( *this == fi ); }
+ bool operator!=( const Lzip_index & li ) const { return !( *this == li ); }
long long udata_size() const
{ if( member_vector.empty() ) return 0;
@@ -71,7 +75,7 @@ public:
// total size including trailing data (if any)
long long file_size() const
- { if( isize >= 0 ) return isize; else return 0; }
+ { if( insize >= 0 ) return insize; else return 0; }
const Block & dblock( const long i ) const
{ return member_vector[i].dblock; }