Differences From Artifact [fabe910a28]:
- File src/OFZIPArchiveEntry.m — part of check-in [3b97fc3cd9] at 2014-01-04 00:24:08 on branch trunk — Update copyright. (user: js, size: 6247) [annotate] [blame] [check-ins using]
To Artifact [0a34c90b44]:
- File
src/OFZIPArchiveEntry.m
— part of check-in
[adf754d5fc]
at
2014-05-25 22:58:08
on branch trunk
— Move of_zip_archive_find_extra_field()
This belongs to OFZIPArchiveEntry. Consequently, it has been renamed to
of_zip_archive_entry_find_extra_field() and made public, so that it can
be used by applications that got the extra field from the
OFZIPArchiveEntry. (user: js, size: 6844) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
25 26 27 28 29 30 31 | #import "autorelease.h" #import "macros.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" | < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 25 26 27 28 29 30 31 32 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 69 70 71 72 73 74 75 | #import "autorelease.h" #import "macros.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" extern uint32_t of_zip_archive_read_field32(uint8_t**, uint16_t*); extern uint64_t of_zip_archive_read_field64(uint8_t**, uint16_t*); void of_zip_archive_entry_find_extra_field(OFDataArray *extraField, uint16_t tag, uint8_t **data, uint16_t *size) { uint8_t *bytes; size_t i, count; bytes = [extraField items]; count = [extraField count]; for (i = 0; i < count;) { uint16_t currentTag, currentSize; if (i + 3 >= count) @throw [OFInvalidFormatException exception]; currentTag = (bytes[i + 1] << 8) | bytes[i]; currentSize = (bytes[i + 3] << 8) | bytes[i + 2]; if (i + 3 + currentSize >= count) @throw [OFInvalidFormatException exception]; if (currentTag == tag) { *data = bytes + i + 4; *size = currentSize; return; } i += 4 + currentSize; } *data = NULL; *size = 0; } @implementation OFZIPArchiveEntry - (instancetype)OF_initWithFile: (OFFile*)file { self = [super init]; @try { |
︙ | ︙ | |||
73 74 75 76 77 78 79 | _fileName = [[file readStringWithLength: fileNameLength encoding: encoding] copy]; _extraField = [[file readDataArrayWithCount: extraFieldLength] retain]; _fileComment = [[file readStringWithLength: fileCommentLength encoding: encoding] copy]; | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | _fileName = [[file readStringWithLength: fileNameLength encoding: encoding] copy]; _extraField = [[file readDataArrayWithCount: extraFieldLength] retain]; _fileComment = [[file readStringWithLength: fileCommentLength encoding: encoding] copy]; of_zip_archive_entry_find_extra_field(_extraField, 0x0001, &ZIP64, &ZIP64Size); if (ZIP64 != NULL) { if (_uncompressedSize == 0xFFFFFFFF) _uncompressedSize = of_zip_archive_read_field64( &ZIP64, &ZIP64Size); if (_compressedSize == 0xFFFFFFFF) |
︙ | ︙ |