Overview
Comment: | ofzip: Show compression method for ZIP archives |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fd5dac720dd39a57e5589ba31a7a4edd |
User & Date: | js on 2018-06-10 14:42:24 |
Other Links: | manifest | tags |
Context
2018-06-10
| ||
15:29 | Add OFMutableLHAArchiveEntry check-in: 60ecab6058 user: js tags: trunk | |
14:42 | ofzip: Show compression method for ZIP archives check-in: fd5dac720d user: js tags: trunk | |
12:29 | OFLHAArchive: Skip compressed entries much faster check-in: 2e354552ad user: js tags: trunk | |
Changes
Modified src/OFLHAArchive.m from [4ab39c71a2] to [f7e8cf8472].
︙ | ︙ | |||
724 725 726 727 728 729 730 | @implementation OFLHAArchive_FileReadStream - (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream entry: (OFLHAArchiveEntry *)entry { self = [super init]; @try { | | | | > | | | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | @implementation OFLHAArchive_FileReadStream - (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream entry: (OFLHAArchiveEntry *)entry { self = [super init]; @try { OFString *compressionMethod; _stream = [stream retain]; compressionMethod = [entry compressionMethod]; if ([compressionMethod isEqual: @"-lh4-"] || [compressionMethod isEqual: @"-lh5-"]) _decompressedStream = [[OFLHAArchive_LHStream alloc] of_initWithStream: stream distanceBits: 4 dictionaryBits: 14]; else if ([compressionMethod isEqual: @"-lh6-"]) _decompressedStream = [[OFLHAArchive_LHStream alloc] of_initWithStream: stream distanceBits: 5 dictionaryBits: 16]; else if ([compressionMethod isEqual: @"-lh7-"]) _decompressedStream = [[OFLHAArchive_LHStream alloc] of_initWithStream: stream distanceBits: 5 dictionaryBits: 17]; else _decompressedStream = [stream retain]; |
︙ | ︙ |
Modified src/OFLHAArchiveEntry.h from [88951356da] to [d2c4f03490].
︙ | ︙ | |||
33 34 35 36 37 38 39 | * archive. */ @interface OFLHAArchiveEntry: OFObject <OFCopying> { #ifdef OF_LHA_ARCHIVE_ENTRY_M @public #endif | | | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | * archive. */ @interface OFLHAArchiveEntry: OFObject <OFCopying> { #ifdef OF_LHA_ARCHIVE_ENTRY_M @public #endif OFString *_fileName, *_Nullable _directoryName, *_compressionMethod; uint32_t _compressedSize, _uncompressedSize; OFDate *_date; uint8_t _level; uint16_t _CRC16; uint8_t _operatingSystemIdentifier; OFString *_Nullable _fileComment; OFNumber *_Nullable _mode, *_Nullable _UID, *_Nullable _GID; OFString *_Nullable _owner, *_Nullable _group; OFDate *_Nullable _modificationDate; OFMutableArray OF_GENERIC(OFData *) *_extensions; } /*! * @brief The file name of the entry. */ @property (readonly, copy, nonatomic) OFString *fileName; /*! * @brief The compression method of the entry. */ @property (readonly, copy, nonatomic) OFString *compressionMethod; /*! * @brief The compressed size of the entry's file. */ @property (readonly, nonatomic) uint32_t compressedSize; /*! |
︙ | ︙ |
Modified src/OFLHAArchiveEntry.m from [8228378a63] to [af0de69839].
︙ | ︙ | |||
260 261 262 263 264 265 266 | entry->_compressedSize -= size; } } } @implementation OFLHAArchiveEntry | > | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | entry->_compressedSize -= size; } } } @implementation OFLHAArchiveEntry @synthesize compressionMethod = _compressionMethod; @synthesize compressedSize = _compressedSize; @synthesize uncompressedSize = _uncompressedSize, date = _date; @synthesize level = _level, CRC16 = _CRC16; @synthesize operatingSystemIdentifier = _operatingSystemIdentifier; @synthesize fileComment = _fileComment, mode = _mode, UID = _UID, GID = _GID; @synthesize owner = _owner, group = _group; @synthesize modificationDate = _modificationDate, extensions = _extensions; |
︙ | ︙ | |||
282 283 284 285 286 287 288 | encoding: (of_string_encoding_t)encoding { self = [super init]; @try { uint32_t date; | | | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | encoding: (of_string_encoding_t)encoding { self = [super init]; @try { uint32_t date; _compressionMethod = [[OFString alloc] initWithCString: header + 2 encoding: OF_STRING_ENCODING_ASCII length: 5]; memcpy(&_compressedSize, header + 7, 4); _compressedSize = OF_BSWAP32_IF_BE(_compressedSize); |
︙ | ︙ | |||
354 355 356 357 358 359 360 | } return self; } - (void)dealloc { | | | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | } return self; } - (void)dealloc { [_compressionMethod release]; [_fileName release]; [_directoryName release]; [_date release]; [_fileComment release]; [_mode release]; [_UID release]; [_GID release]; |
︙ | ︙ | |||
394 395 396 397 398 399 400 | : [OFString stringWithFormat: @"%" PRIo16, [_mode uInt16Value]]); OFString *extensions = [[_extensions description] stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" | | | | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | : [OFString stringWithFormat: @"%" PRIo16, [_mode uInt16Value]]); OFString *extensions = [[_extensions description] stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tCompression method = %@\n" @"\tCompressed size = %" @PRIu32 "\n" @"\tUncompressed size = %" @PRIu32 "\n" @"\tDate = %@\n" @"\tLevel = %u\n" @"\tCRC16 = %04" @PRIX16 @"\n" @"\tOperating system identifier = %c\n" @"\tComment = %@\n" @"\tMode = %@\n" @"\tUID = %@\n" @"\tGID = %@\n" @"\tOwner = %@\n" @"\tGroup = %@\n" @"\tModification date = %@\n" @"\tExtensions: %@" @">", [self class], [self fileName], _compressionMethod, _compressedSize, _uncompressedSize, _date, _level, _CRC16, _operatingSystemIdentifier, _fileComment, mode, _UID, _GID, _owner, _group, _modificationDate, extensions]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |
Modified src/OFZIPArchiveEntry.h from [b4cca6f0e2] to [bd6fa00871].
︙ | ︙ | |||
19 20 21 22 23 24 25 | OF_ASSUME_NONNULL_BEGIN /*! @file */ enum { OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE = 0, | | | > > > > > > > > > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | OF_ASSUME_NONNULL_BEGIN /*! @file */ enum { OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE = 0, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_SHRINK = 1, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_1 = 2, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_2 = 3, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_3 = 4, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_4 = 5, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_IMPLODE = 6, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE = 8, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE64 = 9, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_BZIP2 = 12, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_LZMA = 14, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_WAVPACK = 97, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_PPMD = 98 }; /*! * @brief Attribute compatibility part of ZIP versions. */ enum of_zip_archive_entry_attribute_compatibility { /*! MS-DOS and OS/2 */ |
︙ | ︙ | |||
211 212 213 214 215 216 217 | - (instancetype)initWithFileName: (OFString *)fileName; @end #ifdef __cplusplus extern "C" { #endif /*! | | > > > > > > > > > > | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | - (instancetype)initWithFileName: (OFString *)fileName; @end #ifdef __cplusplus extern "C" { #endif /*! * @brief Converts the ZIP entry version to a string. * * @param version The ZIP entry version to convert to a string * @return The ZIP entry version as a string */ extern OFString *of_zip_archive_entry_version_to_string(uint16_t version); /*! * @brief Convers the ZIP entry compression method to a string. * * @param compressionMethod The ZIP entry compression method to convert to a * string * @return The ZIP entry compression method as a string */ extern OFString *of_zip_archive_entry_compression_method_to_string( uint16_t compressionMethod); /*! * @brief Gets a pointer to and the size of the extensible data field with the * specified tag. * * @param extraField The extra field to search for an extensible data field with * the specified tag * @param tag The tag to look for |
︙ | ︙ |
Modified src/OFZIPArchiveEntry.m from [4035dadee9] to [75020cd35d].
︙ | ︙ | |||
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | @"%u.%u, %s", (version & 0xFF) / 10, (version & 0xFF) % 10, attrCompat]; else return [OFString stringWithFormat: @"%u.%u, unknown %02X", (version % 0xFF) / 10, (version & 0xFF) % 10, version >> 8]; } size_t of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag, uint16_t *size) { const uint8_t *bytes = [extraField items]; size_t count = [extraField count]; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | @"%u.%u, %s", (version & 0xFF) / 10, (version & 0xFF) % 10, attrCompat]; else return [OFString stringWithFormat: @"%u.%u, unknown %02X", (version % 0xFF) / 10, (version & 0xFF) % 10, version >> 8]; } OFString * of_zip_archive_entry_compression_method_to_string(uint16_t compressionMethod) { switch (compressionMethod) { case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE: return @"none"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_SHRINK: return @"Shrink"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_1: return @"Reduce (factor 1)"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_2: return @"Reduce (factor 2)"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_3: return @"Reduce (factor 3)"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_4: return @"Reduce (factor 4)"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_IMPLODE: return @"Implode"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE: return @"Deflate"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE64: return @"Deflate64"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_BZIP2: return @"BZip2"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_LZMA: return @"LZMA"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_WAVPACK: return @"WavPack"; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_PPMD: return @"PPMd"; default: return @"unknown"; } } size_t of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag, uint16_t *size) { const uint8_t *bytes = [extraField items]; size_t count = [extraField count]; |
︙ | ︙ | |||
397 398 399 400 401 402 403 404 405 406 407 408 | { return _localFileHeaderOffset; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tFile comment = %@\n" @"\tGeneral purpose bit flag = %u\n" | > > > < > | | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | { return _localFileHeaderOffset; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *compressionMethod = of_zip_archive_entry_compression_method_to_string( _compressionMethod); OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tFile comment = %@\n" @"\tGeneral purpose bit flag = %u\n" @"\tCompressed size = %" @PRIu64 "\n" @"\tUncompressed size = %" @PRIu64 "\n" @"\tCompression method = %@\n" @"\tModification date = %@\n" @"\tCRC32 = %08" @PRIX32 @"\n" @"\tExtra field = %@\n" @">", [self class], _fileName, _fileComment, _generalPurposeBitFlag, _compressedSize, _uncompressedSize, compressionMethod, [self modificationDate], _CRC32, _extraField]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; |
︙ | ︙ |
Modified utils/ofzip/LHAArchive.m from [88f33686f9] to [5c903f71dd].
︙ | ︙ | |||
171 172 173 174 175 176 177 | [of_stdout writeLine: OF_LOCALIZED( @"list_level", @"Level: %[level]", @"level", level)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( | | | | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | [of_stdout writeLine: OF_LOCALIZED( @"list_level", @"Level: %[level]", @"level", level)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_compression_method", @"Compression method: %[method]", @"method", [entry compressionMethod])]; if ([entry operatingSystemIdentifier] != '\0') { OFString *OSID = [OFString stringWithFormat: @"%c", [entry operatingSystemIdentifier]]; [of_stdout writeString: @"\t"]; |
︙ | ︙ |
Modified utils/ofzip/ZIPArchive.m from [7a34fc0000] to [ca1152d27c].
︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | if (app->_outputLevel >= 1) { OFString *compressedSize = [OFString stringWithFormat: @"%" PRIu64, [entry compressedSize]]; OFString *uncompressedSize = [OFString stringWithFormat: @"%" PRIu64, [entry uncompressedSize]]; OFString *CRC32 = [OFString stringWithFormat: @"%08" PRIX32, [entry CRC32]]; OFString *modificationDate = [[entry modificationDate] localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_compressed_size", @"Compressed: %[size] bytes", @"size", compressedSize)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_uncompressed_size", @"Uncompressed: %[size] bytes", @"size", uncompressedSize)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED(@"list_crc32", @"CRC32: %[crc32]", @"crc32", CRC32)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_modification_date", | > > > > > > > > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | if (app->_outputLevel >= 1) { OFString *compressedSize = [OFString stringWithFormat: @"%" PRIu64, [entry compressedSize]]; OFString *uncompressedSize = [OFString stringWithFormat: @"%" PRIu64, [entry uncompressedSize]]; OFString *compressionMethod = of_zip_archive_entry_compression_method_to_string( [entry compressionMethod]); OFString *CRC32 = [OFString stringWithFormat: @"%08" PRIX32, [entry CRC32]]; OFString *modificationDate = [[entry modificationDate] localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_compressed_size", @"Compressed: %[size] bytes", @"size", compressedSize)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_uncompressed_size", @"Uncompressed: %[size] bytes", @"size", uncompressedSize)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_compression_method", @"Compression method: %[method]", @"method", compressionMethod)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED(@"list_crc32", @"CRC32: %[crc32]", @"crc32", CRC32)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_modification_date", |
︙ | ︙ |
Modified utils/ofzip/lang/de.json from [6ac8dc5514] to [2b84d78f2c].
︙ | ︙ | |||
83 84 85 86 87 88 89 90 | "list_device_minor": "Minor-Nummer des Geräts: %[minor]", "list_type_directory": "Typ: Verzeichnis", "list_type_fifo": "Typ: FIFO", "list_type_contiguous_file": "Typ: Zusammenhängende Datei", "list_type_unknown": "Typ: Unbekannt", "list_compressed_size": "Komprimierte Größe: %[size] Bytes", "list_uncompressed_size": "Unkomprimierte Größe: %[size] Bytes", "list_date": "Datum: %[date]", | > < | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | "list_device_minor": "Minor-Nummer des Geräts: %[minor]", "list_type_directory": "Typ: Verzeichnis", "list_type_fifo": "Typ: FIFO", "list_type_contiguous_file": "Typ: Zusammenhängende Datei", "list_type_unknown": "Typ: Unbekannt", "list_compressed_size": "Komprimierte Größe: %[size] Bytes", "list_uncompressed_size": "Unkomprimierte Größe: %[size] Bytes", "list_compression_method": "Kompressionsmethode: %[method]", "list_date": "Datum: %[date]", "list_osid": "Betriebssystem-Identifikator: %[osid]", "list_version_made_by": "Erstellt mit Version: %[version]", "list_min_version_needed": "Mindestens benötigte Version: %[version]", "list_general_purpose_bit_flag": "General Purpose Bit Flag: %[gpbf]", "list_extra_field": "Extra-Feld: %[extra]", "list_comment": "Kommentar: %[comment]", "refusing_to_extract_file": "Verweigere Entpacken von %[file]!", |
︙ | ︙ |