Index: src/OFMutableTarArchiveEntry.h ================================================================== --- src/OFMutableTarArchiveEntry.h +++ src/OFMutableTarArchiveEntry.h @@ -47,13 +47,18 @@ * @brief The GID of the group. */ @property (readwrite, nonatomic) unsigned long GID; /** - * @brief The size of the file. + * @brief The compressed size of the file. + */ +@property (readwrite, nonatomic) unsigned long long compressedSize; + +/** + * @brief The uncompressed size of the file. */ -@property (readwrite, nonatomic) unsigned long long size; +@property (readwrite, nonatomic) unsigned long long uncompressedSize; /** * @brief The date of the last modification of the file. */ @property (readwrite, retain, nonatomic) OFDate *modificationDate; Index: src/OFMutableTarArchiveEntry.m ================================================================== --- src/OFMutableTarArchiveEntry.m +++ src/OFMutableTarArchiveEntry.m @@ -19,12 +19,13 @@ #import "OFTarArchiveEntry+Private.h" #import "OFString.h" #import "OFDate.h" @implementation OFMutableTarArchiveEntry -@dynamic fileName, mode, UID, GID, size, modificationDate, type, targetFileName; -@dynamic owner, group, deviceMajor, deviceMinor; +@dynamic fileName, mode, UID, GID, compressedSize, uncompressedSize; +@dynamic modificationDate, type, targetFileName, owner, group, deviceMajor; +@dynamic deviceMinor; + (instancetype)entryWithFileName: (OFString *)fileName { return [[[self alloc] initWithFileName: fileName] autorelease]; } @@ -72,13 +73,18 @@ - (void)setGID: (unsigned long)GID { _GID = GID; } -- (void)setSize: (unsigned long long)size +- (void)setCompressedSize: (unsigned long long)compressedSize +{ + _compressedSize = compressedSize; +} + +- (void)setUncompressedSize: (unsigned long long)uncompressedSize { - _size = size; + _uncompressedSize = uncompressedSize; } - (void)setModificationDate: (OFDate *)modificationDate { OFDate *old = _modificationDate; Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -272,11 +272,11 @@ self = [super init]; @try { _entry = [entry copy]; _stream = [stream retain]; - _toRead = entry.size; + _toRead = entry.uncompressedSize; } @catch (id e) { [self release]; @throw e; } @@ -367,11 +367,11 @@ seekToOffset: (OFStreamOffset)_toRead whence: OFSeekCurrent]; _toRead = 0; - size = _entry.size; + size = _entry.uncompressedSize; if (size % 512 != 0) [(OFSeekableStream *)_stream seekToOffset: 512 - (size % 512) whence: OFSeekCurrent]; @@ -388,11 +388,11 @@ [_stream readIntoBuffer: buffer exactLength: (size_t)_toRead]; _toRead = 0; } - size = _entry.size; + size = _entry.uncompressedSize; if (size % 512 != 0) [_stream readIntoBuffer: buffer exactLength: (size_t)(512 - (size % 512))]; } @@ -408,11 +408,11 @@ self = [super init]; @try { _entry = [entry copy]; _stream = [stream retain]; - _toWrite = entry.size; + _toWrite = entry.uncompressedSize; } @catch (id e) { [self release]; @throw e; } @@ -477,11 +477,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; if (_toWrite > 0) @throw [OFTruncatedDataException exception]; - remainder = 512 - _entry.size % 512; + remainder = 512 - _entry.uncompressedSize % 512; if (remainder != 512) { bool didBufferWrites = _stream.buffersWrites; _stream.buffersWrites = true; Index: src/OFTarArchiveEntry.h ================================================================== --- src/OFTarArchiveEntry.h +++ src/OFTarArchiveEntry.h @@ -50,11 +50,11 @@ */ @interface OFTarArchiveEntry: OFObject { OFString *_fileName; unsigned long _mode; - unsigned long long _size; + unsigned long long _compressedSize, _uncompressedSize; unsigned long _UID, _GID; OFDate *_modificationDate; OFTarArchiveEntryType _type; OFString *_Nullable _targetFileName; OFString *_Nullable _owner, *_Nullable _group; @@ -81,13 +81,18 @@ * @brief The GID of the group. */ @property (readonly, nonatomic) unsigned long GID; /** - * @brief The size of the file. + * @brief The compressed size of the file. + */ +@property (readonly, nonatomic) unsigned long long compressedSize; + +/** + * @brief The uncompressed size of the file. */ -@property (readonly, nonatomic) unsigned long long size; +@property (readonly, nonatomic) unsigned long long uncompressedSize; /** * @brief The date of the last modification of the file. */ @property (readonly, retain, nonatomic) OFDate *modificationDate; Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -103,12 +103,14 @@ header + 100, 8, ULONG_MAX); _UID = (unsigned long)octalValueFromBuffer( header + 108, 8, ULONG_MAX); _GID = (unsigned long)octalValueFromBuffer( header + 116, 8, ULONG_MAX); - _size = (unsigned long long)octalValueFromBuffer( + _uncompressedSize = (unsigned long long)octalValueFromBuffer( header + 124, 12, ULLONG_MAX); + _compressedSize = + _uncompressedSize + (512 - _uncompressedSize % 512); _modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: (OFTimeInterval)octalValueFromBuffer( header + 136, 12, ULLONG_MAX)]; _type = header[156]; @@ -173,11 +175,12 @@ OFTarArchiveEntry *copy = [[OFMutableTarArchiveEntry alloc] initWithFileName: _fileName]; @try { copy->_mode = _mode; - copy->_size = _size; + copy->_compressedSize = _compressedSize; + copy->_uncompressedSize = _uncompressedSize; copy->_modificationDate = [_modificationDate copy]; copy->_type = _type; copy->_targetFileName = [_targetFileName copy]; copy->_owner = [_owner copy]; copy->_group = [_group copy]; @@ -209,13 +212,18 @@ - (unsigned long)GID { return _GID; } -- (unsigned long long)size +- (unsigned long long)compressedSize +{ + return _compressedSize; +} + +- (unsigned long long)uncompressedSize { - return _size; + return _uncompressedSize; } - (OFDate *)modificationDate { return _modificationDate; @@ -257,21 +265,23 @@ OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tMode = %06o\n" @"\tUID = %u\n" @"\tGID = %u\n" - @"\tSize = %" PRIu64 @"\n" + @"\tCompressed size = %llu\n" + @"\tUncompressed size = %llu\n" @"\tModification date = %@\n" @"\tType = %u\n" @"\tTarget file name = %@\n" @"\tOwner = %@\n" @"\tGroup = %@\n" @"\tDevice major = %" PRIu32 @"\n" @"\tDevice minor = %" PRIu32 @"\n" @">", - self.class, _fileName, _mode, _UID, _GID, _size, _modificationDate, - _type, _targetFileName, _owner, _group, _deviceMajor, _deviceMinor]; + self.class, _fileName, _mode, _UID, _GID, _compressedSize, + _uncompressedSize, _modificationDate, _type, _targetFileName, + _owner, _group, _deviceMajor, _deviceMinor]; [ret retain]; objc_autoreleasePoolPop(pool); @@ -294,11 +304,11 @@ OFStringEncodingASCII); stringToBuffer(buffer + 116, [OFString stringWithFormat: @"%06" PRIo16 " ", _GID], 8, OFStringEncodingASCII); stringToBuffer(buffer + 124, - [OFString stringWithFormat: @"%011" PRIo64 " ", _size], 12, + [OFString stringWithFormat: @"%011llo ", _uncompressedSize], 12, OFStringEncodingASCII); modificationDate = _modificationDate.timeIntervalSince1970; stringToBuffer(buffer + 136, [OFString stringWithFormat: @"%011llo", modificationDate], 12, OFStringEncodingASCII); Index: utils/ofarc/TarArchive.m ================================================================== --- utils/ofarc/TarArchive.m +++ utils/ofarc/TarArchive.m @@ -113,11 +113,11 @@ if (app->_outputLevel >= 1) { OFString *date = [entry.modificationDate localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; OFString *size = [OFString stringWithFormat: - @"%" PRIu64, entry.size]; + @"%llu", entry.uncompressedSize]; OFString *mode = [OFString stringWithFormat: @"%06o", entry.mode]; OFString *UID = [OFString stringWithFormat: @"%u", entry.UID]; OFString *GID = [OFString stringWithFormat: @@ -279,11 +279,11 @@ OFString *fileName = entry.fileName; OFTarArchiveEntryType type = entry.type; OFString *outFileName, *directory; OFFile *output; OFStream *stream; - uint64_t written = 0, size = entry.size; + unsigned long long written = 0, size = entry.uncompressedSize; int8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) continue; @@ -479,11 +479,11 @@ entry = [OFMutableTarArchiveEntry entryWithFileName: fileName]; #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS entry.mode = attributes.filePOSIXPermissions; #endif - entry.size = attributes.fileSize; + entry.uncompressedSize = attributes.fileSize; entry.modificationDate = attributes.fileModificationDate; #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER entry.UID = attributes.fileOwnerAccountID; entry.GID = attributes.fileGroupOwnerAccountID; @@ -493,24 +493,25 @@ if ([type isEqual: OFFileTypeRegular]) entry.type = OFTarArchiveEntryTypeFile; else if ([type isEqual: OFFileTypeDirectory]) { entry.type = OFTarArchiveEntryTypeDirectory; - entry.size = 0; + entry.uncompressedSize = 0; } else if ([type isEqual: OFFileTypeSymbolicLink]) { entry.type = OFTarArchiveEntryTypeSymlink; entry.targetFileName = attributes.fileSymbolicLinkDestination; - entry.size = 0; + entry.uncompressedSize = 0; } [entry makeImmutable]; output = [_archive streamForWritingEntry: entry]; if (entry.type == OFTarArchiveEntryTypeFile) { - uint64_t written = 0, size = entry.size; + unsigned long long written = 0; + unsigned long long size = entry.uncompressedSize; int8_t percent = -1, newPercent; OFFile *input = [OFFile fileWithPath: fileName mode: @"r"];