︙ | | | ︙ | |
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
@interface OFZIPArchive_FileStream: OFStream
{
OFStream *_stream;
OFFile *_file;
OFZIPArchive_LocalFileHeader *_localFileHeader;
bool _hasDataDescriptor;
size_t _size;
uint32_t _CRC32;
bool _atEndOfStream;
}
- initWithArchiveFile: (OFString*)path
offset: (off_t)offset
localFileHeader: (OFZIPArchive_LocalFileHeader*)localFileHeader;
|
|
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
@interface OFZIPArchive_FileStream: OFStream
{
OFStream *_stream;
OFFile *_file;
OFZIPArchive_LocalFileHeader *_localFileHeader;
bool _hasDataDescriptor;
uint64_t _size;
uint32_t _CRC32;
bool _atEndOfStream;
}
- initWithArchiveFile: (OFString*)path
offset: (off_t)offset
localFileHeader: (OFZIPArchive_LocalFileHeader*)localFileHeader;
|
︙ | | | ︙ | |
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
{
void *pool = objc_autoreleasePoolPush();
size_t i;
if ((off_t)_centralDirectoryOffset != _centralDirectoryOffset)
@throw [OFOutOfRangeException exception];
[_file seekToOffset: _centralDirectoryOffset
whence: SEEK_SET];
_entries = [[OFMutableArray alloc] init];
_pathToEntryMap = [[OFMutableDictionary alloc] init];
for (i = 0; i < _centralDirectoryEntries; i++) {
OFZIPArchiveEntry *entry = [[[OFZIPArchiveEntry alloc]
|
|
|
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
{
void *pool = objc_autoreleasePoolPush();
size_t i;
if ((off_t)_centralDirectoryOffset != _centralDirectoryOffset)
@throw [OFOutOfRangeException exception];
[_file seekToOffset: (off_t)_centralDirectoryOffset
whence: SEEK_SET];
_entries = [[OFMutableArray alloc] init];
_pathToEntryMap = [[OFMutableDictionary alloc] init];
for (i = 0; i < _centralDirectoryEntries; i++) {
OFZIPArchiveEntry *entry = [[[OFZIPArchiveEntry alloc]
|
︙ | | | ︙ | |
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
mode: @"rb"];
}
offset = [entry OF_localFileHeaderOffset];
if ((off_t)offset != offset)
@throw [OFOutOfRangeException exception];
[_file seekToOffset: offset
whence: SEEK_SET];
localFileHeader = [[[OFZIPArchive_LocalFileHeader alloc]
initWithFile: _file] autorelease];
if (![localFileHeader matchesEntry: entry])
@throw [OFInvalidFormatException exception];
|
|
|
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
mode: @"rb"];
}
offset = [entry OF_localFileHeaderOffset];
if ((off_t)offset != offset)
@throw [OFOutOfRangeException exception];
[_file seekToOffset: (off_t)offset
whence: SEEK_SET];
localFileHeader = [[[OFZIPArchive_LocalFileHeader alloc]
initWithFile: _file] autorelease];
if (![localFileHeader matchesEntry: entry])
@throw [OFInvalidFormatException exception];
|
︙ | | | ︙ | |
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
|
if (~_CRC32 != _localFileHeader->_CRC32)
@throw [OFChecksumFailedException exception];
return 0;
}
min = (length < _size ? length : _size);
ret = [_stream readIntoBuffer: buffer
length: min];
_size -= ret;
}
_CRC32 = crc32(_CRC32, buffer, ret);
return ret;
}
@end
|
|
|
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
|
if (~_CRC32 != _localFileHeader->_CRC32)
@throw [OFChecksumFailedException exception];
return 0;
}
min = (length < _size ? length : (size_t)_size);
ret = [_stream readIntoBuffer: buffer
length: min];
_size -= ret;
}
_CRC32 = crc32(_CRC32, buffer, ret);
return ret;
}
@end
|