Differences From Artifact [16b7ebc50b]:
- File
src/OFZIPArchive.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 13876) [annotate] [blame] [check-ins using]
To Artifact [df3e45938b]:
- File
src/OFZIPArchive.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 13892) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
62 63 64 65 66 67 68 | uint16_t _lastModifiedFileTime, _lastModifiedFileDate; uint32_t _CRC32; uint64_t _compressedSize, _uncompressedSize; OFString *_fileName; OFDataArray *_extraField; } | | | | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | uint16_t _lastModifiedFileTime, _lastModifiedFileDate; uint32_t _CRC32; uint64_t _compressedSize, _uncompressedSize; OFString *_fileName; OFDataArray *_extraField; } - initWithStream: (OFStream *)stream; - (bool)matchesEntry: (OFZIPArchiveEntry *)entry; @end @interface OFZIPArchive_FileStream: OFStream { OFStream *_stream, *_decompressedStream; OFZIPArchive_LocalFileHeader *_localFileHeader; bool _hasDataDescriptor; uint64_t _size; uint32_t _CRC32; bool _atEndOfStream, _closed; } - initWithStream: (OFStream *)path localFileHeader: (OFZIPArchive_LocalFileHeader *)localFileHeader; @end uint32_t of_zip_archive_read_field32(uint8_t **data, uint16_t *size) { uint32_t field = 0; |
︙ | ︙ | |||
132 133 134 135 136 137 138 | @throw e; } } @implementation OFZIPArchive @synthesize archiveComment = _archiveComment; | | | | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | @throw e; } } @implementation OFZIPArchive @synthesize archiveComment = _archiveComment; + (instancetype)archiveWithSeekableStream: (OFSeekableStream *)stream { return [[[self alloc] initWithSeekableStream: stream] autorelease]; } #ifdef OF_HAVE_FILES + (instancetype)archiveWithPath: (OFString *)path { return [[[self alloc] initWithPath: path] autorelease]; } #endif - init { OF_INVALID_INIT_METHOD } - initWithSeekableStream: (OFSeekableStream *)stream { self = [super init]; @try { _stream = [stream retain]; [self OF_readZIPInfo]; [self OF_readEntries]; } @catch (id e) { [self release]; @throw e; } return self; } #ifdef OF_HAVE_FILES - initWithPath: (OFString *)path { self = [super init]; @try { _stream = [[OFFile alloc] initWithPath: path mode: @"rb"]; |
︙ | ︙ | |||
318 319 320 321 322 323 324 | [_entries makeImmutable]; [_pathToEntryMap makeImmutable]; objc_autoreleasePoolPop(pool); } | | | | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | [_entries makeImmutable]; [_pathToEntryMap makeImmutable]; objc_autoreleasePoolPop(pool); } - (OFArray *)entries { return [[_entries copy] autorelease]; } - (OFStream *)streamForReadingFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFZIPArchiveEntry *entry = [_pathToEntryMap objectForKey: path]; OFZIPArchive_LocalFileHeader *localFileHeader; int64_t offset64; if (entry == nil) |
︙ | ︙ | |||
370 371 372 373 374 375 376 | objc_autoreleasePoolPop(pool); return [[_lastReturnedStream retain] autorelease]; } @end @implementation OFZIPArchive_LocalFileHeader | | | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | objc_autoreleasePoolPop(pool); return [[_lastReturnedStream retain] autorelease]; } @end @implementation OFZIPArchive_LocalFileHeader - initWithStream: (OFStream *)stream { self = [super init]; @try { uint16_t fileNameLength, extraFieldLength; of_string_encoding_t encoding; uint8_t *ZIP64; |
︙ | ︙ | |||
432 433 434 435 436 437 438 | { [_fileName release]; [_extraField release]; [super dealloc]; } | | | | | 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 463 464 465 466 467 468 | { [_fileName release]; [_extraField release]; [super dealloc]; } - (bool)matchesEntry: (OFZIPArchiveEntry *)entry { if (_compressionMethod != [entry compressionMethod] || _lastModifiedFileTime != [entry OF_lastModifiedFileTime] || _lastModifiedFileDate != [entry OF_lastModifiedFileDate]) return false; if (!(_generalPurposeBitFlag & (1 << 3))) if (_CRC32 != [entry CRC32] || _compressedSize != [entry compressedSize] || _uncompressedSize != [entry uncompressedSize]) return false; if (![_fileName isEqual: [entry fileName]]) return false; return true; } @end @implementation OFZIPArchive_FileStream - initWithStream: (OFStream *)stream localFileHeader: (OFZIPArchive_LocalFileHeader *)localFileHeader { self = [super init]; @try { _stream = [stream retain]; switch (localFileHeader->_compressionMethod) { |
︙ | ︙ | |||
506 507 508 509 510 511 512 | } - (bool)lowlevelIsAtEndOfStream { return _atEndOfStream; } | | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | } - (bool)lowlevelIsAtEndOfStream { return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t min, ret; if (_atEndOfStream || _closed) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; |
︙ | ︙ |