Differences From Artifact [3ab00e0dd7]:
- File src/OFZIPArchive.m — part of check-in [504e13cf00] at 2017-05-13 22:38:02 on branch trunk — Reduce retain + autorelease (user: js, size: 13832) [annotate] [blame] [check-ins using]
To Artifact [af4fea4ffc]:
- File
src/OFZIPArchive.m
— part of check-in
[6b77a5dd8b]
at
2017-05-21 21:28:57
on branch trunk
— Prefix private methods with of_ instead of OF_
This matches Apple's style. (user: js, size: 13832) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
47 48 49 50 51 52 53 | * FIXME: Current limitations: * - Split archives are not supported. * - Write support is missing. * - Encrypted files cannot be read. */ @interface OFZIPArchive () | | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | * FIXME: Current limitations: * - Split archives are not supported. * - Write support is missing. * - Encrypted files cannot be read. */ @interface OFZIPArchive () - (void)of_readZIPInfo; - (void)of_readEntries; @end @interface OFZIPArchive_LocalFileHeader: OFObject { @public uint16_t _minVersionNeeded, _generalPurposeBitFlag, _compressionMethod; uint16_t _lastModifiedFileTime, _lastModifiedFileDate; |
︙ | ︙ | |||
156 157 158 159 160 161 162 | - initWithSeekableStream: (OFSeekableStream *)stream { self = [super init]; @try { _stream = [stream retain]; | | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | - 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; } |
︙ | ︙ | |||
192 193 194 195 196 197 198 | [_entries release]; [_pathToEntryMap release]; [_lastReturnedStream release]; [super dealloc]; } | | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | [_entries release]; [_pathToEntryMap release]; [_lastReturnedStream release]; [super dealloc]; } - (void)of_readZIPInfo { void *pool = objc_autoreleasePoolPush(); uint16_t commentLength; of_offset_t offset = -22; bool valid = false; do { |
︙ | ︙ | |||
281 282 283 284 285 286 287 | _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; } objc_autoreleasePoolPop(pool); } | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; } objc_autoreleasePoolPop(pool); } - (void)of_readEntries { void *pool = objc_autoreleasePoolPush(); if (_centralDirectoryOffset < 0 || (of_offset_t)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat(_stream, (of_offset_t)_centralDirectoryOffset, SEEK_SET); _entries = [[OFMutableArray alloc] init]; _pathToEntryMap = [[OFMutableDictionary alloc] init]; for (size_t i = 0; i < _centralDirectoryEntries; i++) { OFZIPArchiveEntry *entry = [[[OFZIPArchiveEntry alloc] of_initWithStream: _stream] autorelease]; if ([_pathToEntryMap objectForKey: [entry fileName]] != nil) @throw [OFInvalidFormatException exception]; [_entries addObject: entry]; [_pathToEntryMap setObject: entry forKey: [entry fileName]]; |
︙ | ︙ | |||
334 335 336 337 338 339 340 | mode: @"rb" errNo: ENOENT]; [_lastReturnedStream close]; [_lastReturnedStream release]; _lastReturnedStream = nil; | | | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | mode: @"rb" errNo: ENOENT]; [_lastReturnedStream close]; [_lastReturnedStream release]; _lastReturnedStream = nil; offset64 = [entry of_localFileHeaderOffset]; if (offset64 < 0 || (of_offset_t)offset64 != offset64) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat(_stream, (of_offset_t)offset64, SEEK_SET); localFileHeader = [[[OFZIPArchive_LocalFileHeader alloc] initWithStream: _stream] autorelease]; |
︙ | ︙ | |||
430 431 432 433 434 435 436 | [super dealloc]; } - (bool)matchesEntry: (OFZIPArchiveEntry *)entry { if (_compressionMethod != [entry compressionMethod] || | | | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | [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; |
︙ | ︙ |