summaryrefslogtreecommitdiffstats
path: root/extended.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-03-16 06:45:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-03-16 06:45:57 +0000
commit85afea931c3a021e186e81f55b9d969f14d14e41 (patch)
tree66639fa7ecd0ae38763a9097ceed2a577548623a /extended.cc
parentAdding upstream version 0.13. (diff)
downloadtarlz-85afea931c3a021e186e81f55b9d969f14d14e41.tar.xz
tarlz-85afea931c3a021e186e81f55b9d969f14d14e41.zip
Adding upstream version 0.14.upstream/0.14
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extended.cc')
-rw-r--r--extended.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/extended.cc b/extended.cc
index 5931be2..39b0f5a 100644
--- a/extended.cc
+++ b/extended.cc
@@ -201,7 +201,9 @@ bool Extended::parse( const char * const buf, const unsigned long long edsize,
if( rest > 5 && std::memcmp( tail, "path=", 5 ) == 0 )
{
if( path_.size() && !permissive ) return false;
- path_.assign( tail + 5, rest - 5 );
+ unsigned long long len = rest - 5;
+ while( len > 1 && tail[5+len-1] == '/' ) --len; // trailing '/'
+ path_.assign( tail + 5, len );
// this also truncates path_ at the first embedded null character
path_.assign( remove_leading_dotslash( path_.c_str() ) );
}
@@ -275,3 +277,19 @@ void Extended::fill_from_ustar( const Tar_header header )
( typeflag == tf_regular || typeflag == tf_hiperf ) )
file_size( parse_octal( header + size_o, size_l ) );
}
+
+
+/* Returns file size from record or from ustar header, and resets file_size_.
+ Used for fast parsing of headers in uncompressed archives. */
+unsigned long long Extended::get_file_size_and_reset( const Tar_header header )
+ {
+ const unsigned long long tmp = file_size_;
+ file_size( 0 );
+ const Typeflag typeflag = (Typeflag)header[typeflag_o];
+ if( typeflag == tf_regular || typeflag == tf_hiperf )
+ {
+ if( tmp == 0 ) return parse_octal( header + size_o, size_l );
+ else return tmp;
+ }
+ return 0;
+ }