Overview
Comment: | OFZIPArchiveEntry: Make (un)compressedSize ull
This is for consistency with OFTarArchiveEntry and OFLHAArchiveEntry. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
94c326ab78f32a9cfb684d4547989c42 |
User & Date: | js on 2022-08-27 20:33:53 |
Other Links: | manifest | tags |
Context
2022-08-27
| ||
20:39 | Rename OFFileOffset -> OFStreamOffset check-in: 51589c6496 user: js tags: trunk | |
20:33 | OFZIPArchiveEntry: Make (un)compressedSize ull check-in: 94c326ab78 user: js tags: trunk | |
20:23 | OFLHAArchiveEntry: Make (un)compressedSize ull check-in: 6f13f74134 user: js tags: trunk | |
Changes
Modified src/OFMutableZIPArchiveEntry.h from [2c15cacfc2] to [51e6a92030].
︙ | ︙ | |||
88 89 90 91 92 93 94 | */ @property (readwrite, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; /** * @brief The compressed size of the entry's file. */ | | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | */ @property (readwrite, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; /** * @brief The compressed size of the entry's file. */ @property (readwrite, nonatomic) unsigned long long compressedSize; /** * @brief The uncompressed size of the entry's file. */ @property (readwrite, nonatomic) unsigned long long uncompressedSize; /** * @brief The CRC32 checksum of the entry's file. */ @property (readwrite, nonatomic) uint32_t CRC32; /** |
︙ | ︙ |
Modified src/OFMutableZIPArchiveEntry.m from [d21bf4e040] to [5de5ffdaad].
︙ | ︙ | |||
138 139 140 141 142 143 144 | - (void)setCompressionMethod: (OFZIPArchiveEntryCompressionMethod)compressionMethod { _compressionMethod = compressionMethod; } | | | | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | - (void)setCompressionMethod: (OFZIPArchiveEntryCompressionMethod)compressionMethod { _compressionMethod = compressionMethod; } - (void)setCompressedSize: (unsigned long long)compressedSize { _compressedSize = compressedSize; } - (void)setUncompressedSize: (unsigned long long)uncompressedSize { _uncompressedSize = uncompressedSize; } - (void)setCRC32: (uint32_t)CRC32 { _CRC32 = CRC32; |
︙ | ︙ |
Modified src/OFZIPArchive.m from [eb2198be22] to [e9a337a52f].
︙ | ︙ | |||
79 80 81 82 83 84 85 | @end OF_DIRECT_MEMBERS @interface OFZIPArchiveFileReadStream: OFStream { OFStream *_stream, *_decompressedStream; OFZIPArchiveEntry *_entry; | | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | @end OF_DIRECT_MEMBERS @interface OFZIPArchiveFileReadStream: OFStream { OFStream *_stream, *_decompressedStream; OFZIPArchiveEntry *_entry; unsigned long long _toRead; uint32_t _CRC32; bool _atEndOfStream; } - (instancetype)of_initWithStream: (OFStream *)stream entry: (OFZIPArchiveEntry *)entry; @end OF_DIRECT_MEMBERS @interface OFZIPArchiveFileWriteStream: OFStream { OFStream *_stream; uint32_t _CRC32; @public unsigned long long _bytesWritten; OFMutableZIPArchiveEntry *_entry; } - (instancetype)initWithStream: (OFStream *)stream entry: (OFMutableZIPArchiveEntry *)entry; @end |
︙ | ︙ | |||
406 407 408 409 410 411 412 | if ((_mode == modeWrite || _mode == modeAppend) && [_lastReturnedStream isKindOfClass: [OFZIPArchiveFileWriteStream class]]) { OFZIPArchiveFileWriteStream *stream = (OFZIPArchiveFileWriteStream *)_lastReturnedStream; | | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | if ((_mode == modeWrite || _mode == modeAppend) && [_lastReturnedStream isKindOfClass: [OFZIPArchiveFileWriteStream class]]) { OFZIPArchiveFileWriteStream *stream = (OFZIPArchiveFileWriteStream *)_lastReturnedStream; if (ULLONG_MAX - _offset < stream->_bytesWritten) @throw [OFOutOfRangeException exception]; _offset += stream->_bytesWritten; if (stream->_entry != nil) { [_entries addObject: stream->_entry]; [_pathToEntryMap setObject: stream->_entry |
︙ | ︙ | |||
799 800 801 802 803 804 805 | @throw [OFTruncatedDataException exception]; #if SIZE_MAX >= UINT64_MAX if (length > UINT64_MAX) @throw [OFOutOfRangeException exception]; #endif | | | 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | @throw [OFTruncatedDataException exception]; #if SIZE_MAX >= UINT64_MAX if (length > UINT64_MAX) @throw [OFOutOfRangeException exception]; #endif if (length > _toRead) length = (size_t)_toRead; ret = [_decompressedStream readIntoBuffer: buffer length: length]; _toRead -= ret; _CRC32 = OFCRC32(_CRC32, buffer, ret); |
︙ | ︙ | |||
882 883 884 885 886 887 888 | - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { #if SIZE_MAX >= INT64_MAX if (length > INT64_MAX) @throw [OFOutOfRangeException exception]; #endif | | | | > > > | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 | - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { #if SIZE_MAX >= INT64_MAX if (length > INT64_MAX) @throw [OFOutOfRangeException exception]; #endif if (ULLONG_MAX - _bytesWritten < length) @throw [OFOutOfRangeException exception]; @try { [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); _bytesWritten += e.bytesWritten; _CRC32 = OFCRC32(_CRC32, buffer, e.bytesWritten); if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } _bytesWritten += length; _CRC32 = OFCRC32(_CRC32, buffer, length); return length; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_bytesWritten > UINT64_MAX) @throw [OFOutOfRangeException exception]; [_stream writeLittleEndianInt32: 0x08074B50]; [_stream writeLittleEndianInt32: _CRC32]; [_stream writeLittleEndianInt64: (uint64_t)_bytesWritten]; [_stream writeLittleEndianInt64: (uint64_t)_bytesWritten]; [_stream release]; _stream = nil; _entry.CRC32 = ~_CRC32; _entry.compressedSize = _bytesWritten; _entry.uncompressedSize = _bytesWritten; |
︙ | ︙ |
Modified src/OFZIPArchiveEntry.h from [6531c47312] to [1aff4ade49].
︙ | ︙ | |||
104 105 106 107 108 109 110 | { OFZIPArchiveEntryAttributeCompatibility _versionMadeBy; OFZIPArchiveEntryAttributeCompatibility _minVersionNeeded; uint16_t _generalPurposeBitFlag; OFZIPArchiveEntryCompressionMethod _compressionMethod; uint16_t _lastModifiedFileTime, _lastModifiedFileDate; uint32_t _CRC32; | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | { OFZIPArchiveEntryAttributeCompatibility _versionMadeBy; OFZIPArchiveEntryAttributeCompatibility _minVersionNeeded; uint16_t _generalPurposeBitFlag; OFZIPArchiveEntryCompressionMethod _compressionMethod; uint16_t _lastModifiedFileTime, _lastModifiedFileDate; uint32_t _CRC32; unsigned long long _compressedSize, _uncompressedSize; OFString *_fileName; OFData *_Nullable _extraField; OFString *_Nullable _fileComment; uint32_t _startDiskNumber; uint16_t _internalAttributes; uint32_t _versionSpecificAttributes; int64_t _localFileHeaderOffset; |
︙ | ︙ | |||
178 179 180 181 182 183 184 | */ @property (readonly, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; /** * @brief The compressed size of the entry's file. */ | | | | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | */ @property (readonly, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; /** * @brief The compressed size of the entry's file. */ @property (readonly, nonatomic) unsigned long long compressedSize; /** * @brief The uncompressed size of the entry's file. */ @property (readonly, nonatomic) unsigned long long uncompressedSize; /** * @brief The CRC32 checksum of the entry's file. */ @property (readonly, nonatomic) uint32_t CRC32; /** |
︙ | ︙ |
Modified src/OFZIPArchiveEntry.m from [279399b274] to [a4f0074e93].
︙ | ︙ | |||
362 363 364 365 366 367 368 | } - (OFZIPArchiveEntryCompressionMethod)compressionMethod { return _compressionMethod; } | | | | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | } - (OFZIPArchiveEntryCompressionMethod)compressionMethod { return _compressionMethod; } - (unsigned long long)compressedSize { return _compressedSize; } - (unsigned long long)uncompressedSize { return _uncompressedSize; } - (uint32_t)CRC32 { return _CRC32; |
︙ | ︙ |
Modified utils/ofarc/ZIPArchive.m from [0cdfabe7b0] to [6652b0186c].
︙ | ︙ | |||
244 245 246 247 248 249 250 | for (OFZIPArchiveEntry *entry in _archive.entries) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; OFString *outFileName, *directory; OFStream *stream; OFFile *output; | | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | for (OFZIPArchiveEntry *entry in _archive.entries) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; OFString *outFileName, *directory; OFStream *stream; OFFile *output; unsigned long long written = 0, size = entry.uncompressedSize; int8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) continue; [missing removeObject: fileName]; |
︙ | ︙ | |||
435 436 437 438 439 440 441 | [OFStdOut writeString: OF_LOCALIZED(@"adding_file", @"Adding %[file]...", @"file", fileName)]; entry = [OFMutableZIPArchiveEntry entryWithFileName: fileName]; size = (isDirectory ? 0 : attributes.fileSize); | | | | | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | [OFStdOut writeString: OF_LOCALIZED(@"adding_file", @"Adding %[file]...", @"file", fileName)]; entry = [OFMutableZIPArchiveEntry entryWithFileName: fileName]; size = (isDirectory ? 0 : attributes.fileSize); if (size < 0 || size > ULLONG_MAX) @throw [OFOutOfRangeException exception]; entry.compressedSize = size; entry.uncompressedSize = size; entry.compressionMethod = OFZIPArchiveEntryCompressionMethodNone; entry.modificationDate = attributes.fileModificationDate; [entry makeImmutable]; |
︙ | ︙ |