summaryrefslogtreecommitdiffstats
path: root/extended.cc
diff options
context:
space:
mode:
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;
+ }