Comment: | Rename all remaining enums |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | new-naming-convention |
Files: | files | file ages | folders |
SHA3-256: |
aa74e852201ff139cc74b00600fceccd |
User & Date: | js on 2021-04-17 18:36:18 |
Other Links: | branch diff | manifest | tags |
2021-04-17
| ||
20:47 | Rename atomic operations check-in: dfaf287249 user: js tags: new-naming-convention | |
18:36 | Rename all remaining enums check-in: aa74e85220 user: js tags: new-naming-convention | |
17:49 | Rename JSON representation options check-in: 5ce8c7cca7 user: js tags: new-naming-convention | |
Modified src/OFGZIPStream.h from [5d6697a8b2] to [dc70b7b057].
︙ | ︙ | |||
29 30 31 32 33 34 35 | OFGZIPStreamOperatingSystemVMS = 2, OFGZIPStreamOperatingSystemUNIX = 3, OFGZIPStreamOperatingSystemVM_CMS = 4, OFGZIPStreamOperatingSystemAtariTOS = 5, OFGZIPStreamOperatingSystemHPFS = 6, OFGZIPStreamOperatingSystemMacintosh = 7, OFGZIPStreamOperatingSystemZSystem = 8, | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | OFGZIPStreamOperatingSystemVMS = 2, OFGZIPStreamOperatingSystemUNIX = 3, OFGZIPStreamOperatingSystemVM_CMS = 4, OFGZIPStreamOperatingSystemAtariTOS = 5, OFGZIPStreamOperatingSystemHPFS = 6, OFGZIPStreamOperatingSystemMacintosh = 7, OFGZIPStreamOperatingSystemZSystem = 8, OFGZIPStreamOperatingSystemCPM = 9, OFGZIPStreamOperatingSystemTOPS20 = 10, OFGZIPStreamOperatingSystemNTFS = 11, OFGZIPStreamOperatingSystemQDO = 12, OFGZIPStreamOperatingSystemAcornRISCOS = 13, OFGZIPStreamOperatingSystemUnknown = 255 } OFGZIPStreamOperatingSystem; |
︙ | ︙ |
Modified src/OFLHAArchive.h from [8b3e09cc61] to [4b0e86f56f].
︙ | ︙ | |||
28 29 30 31 32 33 34 | * @brief A class for accessing and manipulating LHA files. */ OF_SUBCLASSING_RESTRICTED @interface OFLHAArchive: OFObject { OFStream *_stream; enum { | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | * @brief A class for accessing and manipulating LHA files. */ OF_SUBCLASSING_RESTRICTED @interface OFLHAArchive: OFObject { OFStream *_stream; enum { OFLHAArchiveModeRead, OFLHAArchiveModeWrite, OFLHAArchiveModeAppend } _mode; OFStringEncoding _encoding; OFStream *_Nullable _lastReturnedStream; } /** * @brief The encoding to use for the archive. Defaults to ISO 8859-1. |
︙ | ︙ |
Modified src/OFLHAArchive.m from [ad2e9808eb] to [53cd493a82].
︙ | ︙ | |||
91 92 93 94 95 96 97 | { self = [super init]; @try { _stream = [stream retain]; if ([mode isEqual: @"r"]) | | | | | | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | { self = [super init]; @try { _stream = [stream retain]; if ([mode isEqual: @"r"]) _mode = OFLHAArchiveModeRead; else if ([mode isEqual: @"w"]) _mode = OFLHAArchiveModeWrite; else if ([mode isEqual: @"a"]) _mode = OFLHAArchiveModeAppend; else @throw [OFInvalidArgumentException exception]; if ((_mode == OFLHAArchiveModeWrite || _mode == OFLHAArchiveModeAppend) && ![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; if (_mode == OFLHAArchiveModeAppend) [(OFSeekableStream *)_stream seekToOffset: 0 whence: SEEK_END]; _encoding = OFStringEncodingISO8859_1; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
151 152 153 154 155 156 157 | - (OFLHAArchiveEntry *)nextEntry { OFLHAArchiveEntry *entry; char header[21]; size_t headerLen; | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | - (OFLHAArchiveEntry *)nextEntry { OFLHAArchiveEntry *entry; char header[21]; size_t headerLen; if (_mode != OFLHAArchiveModeRead) @throw [OFInvalidArgumentException exception]; [(OFLHAArchiveFileReadStream *)_lastReturnedStream of_skip]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ |
︙ | ︙ | |||
192 193 194 195 196 197 198 | entry: entry]; return entry; } - (OFStream *)streamForReadingCurrentEntry { | | | < | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | entry: entry]; return entry; } - (OFStream *)streamForReadingCurrentEntry { if (_mode != OFLHAArchiveModeRead) @throw [OFInvalidArgumentException exception]; if (_lastReturnedStream == nil) @throw [OFInvalidArgumentException exception]; return [[(OFLHAArchiveFileReadStream *)_lastReturnedStream retain] autorelease]; } - (OFStream *)streamForWritingEntry: (OFLHAArchiveEntry *)entry { OFString *compressionMethod; if (_mode != OFLHAArchiveModeWrite && _mode != OFLHAArchiveModeAppend) @throw [OFInvalidArgumentException exception]; compressionMethod = entry.compressionMethod; if (![compressionMethod isEqual: @"-lh0-"] && ![compressionMethod isEqual: @"-lhd-"]) @throw [OFNotImplementedException exceptionWithSelector: _cmd |
︙ | ︙ |
Modified src/OFLHADecompressingStream.h from [8c1fbf6c83] to [22e7ad21f5].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * file. */ #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN #define OFLHADecompressingStreamBufferSize 4096 OF_DIRECT_MEMBERS @interface OFLHADecompressingStream: OFStream { OFStream *_stream; uint8_t _distanceBits, _dictionaryBits; unsigned char _buffer[OFLHADecompressingStreamBufferSize]; uint32_t _bytesConsumed; uint16_t _bufferIndex, _bufferLength; uint8_t _byte; uint8_t _bitIndex, _savedBitsLength; uint16_t _savedBits; unsigned char *_slidingWindow; uint32_t _slidingWindowIndex, _slidingWindowMask; |
︙ | ︙ |
Modified src/OFLHADecompressingStream.m from [50a6bfc7bc] to [d371e2f82d].
︙ | ︙ | |||
56 57 58 59 60 61 62 | if OF_UNLIKELY (stream->_bitIndex == 8) { if OF_LIKELY (stream->_bufferIndex < stream->_bufferLength) stream->_byte = stream->_buffer[stream->_bufferIndex++]; else { const size_t bufferLength = | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | if OF_UNLIKELY (stream->_bitIndex == 8) { if OF_LIKELY (stream->_bufferIndex < stream->_bufferLength) stream->_byte = stream->_buffer[stream->_bufferIndex++]; else { const size_t bufferLength = OFLHADecompressingStreamBufferSize; size_t length = [stream->_stream readIntoBuffer: stream->_buffer length: bufferLength]; stream->_bytesConsumed += (uint32_t)length; if OF_UNLIKELY (length < 1) { |
︙ | ︙ |
Modified src/OFMutableZIPArchiveEntry.h from [0cb20b81d1] to [bd5d60ef28].
︙ | ︙ | |||
48 49 50 51 52 53 54 | @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFData *extraField; /** * @brief The version which made the entry. * * The lower 8 bits are the ZIP specification version.@n * The upper 8 bits are the attribute compatibility. | | | > | | > | | | | | | > | 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFData *extraField; /** * @brief The version which made the entry. * * The lower 8 bits are the ZIP specification version.@n * The upper 8 bits are the attribute compatibility. * See @ref OFZIPArchiveEntryAttributeCompatibility. */ @property (readwrite, nonatomic) OFZIPArchiveEntryAttributeCompatibility versionMadeBy; /** * @brief The minimum version required to extract the file. * * The lower 8 bits are the ZIP specification version.@n * The upper 8 bits are the attribute compatibility. * See @ref OFZIPArchiveEntryAttributeCompatibility. */ @property (readwrite, nonatomic) OFZIPArchiveEntryAttributeCompatibility minVersionNeeded; /** * @brief The last modification date of the entry's file. * * @note Due to limitations of the ZIP format, this has only 2 second precision. */ @property (readwrite, retain, nonatomic) OFDate *modificationDate; /** * @brief The compression method of the entry. * * Supported values are: * Value | Description * --------------------------------------------|--------------- * OFZIPArchiveEntryCompressionMethodNone | No compression * OFZIPArchiveEntryCompressionMethodDeflate | Deflate * OFZIPArchiveEntryCompressionMethodDeflate64 | Deflate64 * * Other values may be returned, but the file cannot be extracted then. */ @property (readwrite, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; /** * @brief The compressed size of the entry's file. */ @property (readwrite, nonatomic) uint64_t compressedSize; /** |
︙ | ︙ |
Modified src/OFMutableZIPArchiveEntry.m from [0b4e9c4fc9] to [fe9804e5f1].
︙ | ︙ | |||
81 82 83 84 85 86 87 | old = _extraField; _extraField = [extraField copy]; [old release]; objc_autoreleasePoolPop(pool); } | | > | > | > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | old = _extraField; _extraField = [extraField copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setVersionMadeBy: (OFZIPArchiveEntryAttributeCompatibility)versionMadeBy { _versionMadeBy = versionMadeBy; } - (void)setMinVersionNeeded: (OFZIPArchiveEntryAttributeCompatibility)minVersionNeeded { _minVersionNeeded = minVersionNeeded; } - (void)setModificationDate: (OFDate *)date { void *pool = objc_autoreleasePoolPush(); _lastModifiedFileDate = (((date.localYear - 1980) & 0xFF) << 9) | ((date.localMonthOfYear & 0x0F) << 5) | (date.localDayOfMonth & 0x1F); _lastModifiedFileTime = ((date.localHour & 0x1F) << 11) | ((date.localMinute & 0x3F) << 5) | ((date.second >> 1) & 0x0F); objc_autoreleasePoolPop(pool); } - (void)setCompressionMethod: (OFZIPArchiveEntryCompressionMethod)compressionMethod { _compressionMethod = compressionMethod; } - (void)setCompressedSize: (uint64_t)compressedSize { _compressedSize = compressedSize; |
︙ | ︙ |
Modified src/OFTCPSocketSOCKS5Connector.h from [2e0767356b] to [444395c847].
︙ | ︙ | |||
26 27 28 29 30 31 32 | uint16_t _port; id <OFTCPSocketDelegate> _Nullable _delegate; #ifdef OF_HAVE_BLOCKS OFTCPSocketAsyncConnectBlock _Nullable _block; #endif id _Nullable _exception; enum { | | | | | | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | uint16_t _port; id <OFTCPSocketDelegate> _Nullable _delegate; #ifdef OF_HAVE_BLOCKS OFTCPSocketAsyncConnectBlock _Nullable _block; #endif id _Nullable _exception; enum { OFSOCKS5StateSendAuthentication = 1, OFSOCKS5StateReadVersion, OFSOCKS5StateSendRequest, OFSOCKS5StateReadResponse, OFSOCKS5StateReadAddress, OFSOCKS5StateReadAddressLength, } _SOCKS5State; /* Longest read is domain name (max 255 bytes) + port */ unsigned char _buffer[257]; OFMutableData *_Nullable _request; } - (instancetype)initWithSocket: (OFTCPSocket *)sock |
︙ | ︙ |
Modified src/OFTCPSocketSOCKS5Connector.m from [e22943df87] to [e52c5629f6].
︙ | ︙ | |||
102 103 104 105 106 107 108 | _exception = [exception retain]; [self didConnect]; return; } data = [OFData dataWithItems: "\x05\x01\x00" count: 3]; | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | _exception = [exception retain]; [self didConnect]; return; } data = [OFData dataWithItems: "\x05\x01\x00" count: 3]; _SOCKS5State = OFSOCKS5StateSendAuthentication; [_socket asyncWriteData: data runLoopMode: [OFRunLoop currentRunLoop].currentMode]; } - (bool)stream: (OFStream *)sock didReadIntoBuffer: (void *)buffer length: (size_t)length |
︙ | ︙ | |||
127 128 129 130 131 132 133 | [self didConnect]; return false; } runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | [self didConnect]; return false; } runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { case OFSOCKS5StateReadVersion: SOCKSVersion = buffer; if (SOCKSVersion[0] != 5 || SOCKSVersion[1] != 0) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: self |
︙ | ︙ | |||
153 154 155 156 157 158 159 | [_request addItem: &hostLength]; [_request addItems: _host.UTF8String count: hostLength]; port[0] = _port >> 8; port[1] = _port & 0xFF; [_request addItems: port count: 2]; | | | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | [_request addItem: &hostLength]; [_request addItems: _host.UTF8String count: hostLength]; port[0] = _port >> 8; port[1] = _port & 0xFF; [_request addItems: port count: 2]; _SOCKS5State = OFSOCKS5StateSendRequest; [_socket asyncWriteData: _request runLoopMode: runLoopMode]; return false; case OFSOCKS5StateReadResponse: response = buffer; if (response[0] != 5 || response[2] != 0) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: self |
︙ | ︙ | |||
215 216 217 218 219 220 221 | [self didConnect]; return false; } /* Skip the rest of the response */ switch (response[3]) { case 1: /* IPv4 */ | | | | | | | | 215 216 217 218 219 220 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 252 253 254 255 256 257 258 259 260 261 262 263 | [self didConnect]; return false; } /* Skip the rest of the response */ switch (response[3]) { case 1: /* IPv4 */ _SOCKS5State = OFSOCKS5StateReadAddress; [_socket asyncReadIntoBuffer: _buffer exactLength: 4 + 2 runLoopMode: runLoopMode]; return false; case 3: /* Domain name */ _SOCKS5State = OFSOCKS5StateReadAddressLength; [_socket asyncReadIntoBuffer: _buffer exactLength: 1 runLoopMode: runLoopMode]; return false; case 4: /* IPv6 */ _SOCKS5State = OFSOCKS5StateReadAddress; [_socket asyncReadIntoBuffer: _buffer exactLength: 16 + 2 runLoopMode: runLoopMode]; return false; default: _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: self errNo: EPROTONOSUPPORT]; [self didConnect]; return false; } return false; case OFSOCKS5StateReadAddress: [self didConnect]; return false; case OFSOCKS5StateReadAddressLength: addressLength = buffer; _SOCKS5State = OFSOCKS5StateReadAddress; [_socket asyncReadIntoBuffer: _buffer exactLength: addressLength[0] + 2 runLoopMode: runLoopMode]; return false; default: assert(0); return false; |
︙ | ︙ | |||
276 277 278 279 280 281 282 | [self didConnect]; return nil; } runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { | | | | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | [self didConnect]; return nil; } runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { case OFSOCKS5StateSendAuthentication: _SOCKS5State = OFSOCKS5StateReadVersion; [_socket asyncReadIntoBuffer: _buffer exactLength: 2 runLoopMode: runLoopMode]; return nil; case OFSOCKS5StateSendRequest: [_request release]; _request = nil; _SOCKS5State = OFSOCKS5StateReadResponse; [_socket asyncReadIntoBuffer: _buffer exactLength: 4 runLoopMode: runLoopMode]; return nil; default: assert(0); return nil; } } @end |
Modified src/OFXMLParser.h from [88a3556818] to [1fb96ae9fc].
︙ | ︙ | |||
126 127 128 129 130 131 132 | * OFXMLParser is an event-based XML parser which calls the delegate's callbacks * as soon as it finds something, thus suitable for streams as well. */ OF_SUBCLASSING_RESTRICTED @interface OFXMLParser: OFObject { id <OFXMLParserDelegate> _Nullable _delegate; | | | | | | | | | | | | | | | | | | | | | | | 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 153 154 155 156 157 158 159 160 | * OFXMLParser is an event-based XML parser which calls the delegate's callbacks * as soon as it finds something, thus suitable for streams as well. */ OF_SUBCLASSING_RESTRICTED @interface OFXMLParser: OFObject { id <OFXMLParserDelegate> _Nullable _delegate; enum { OFXMLParserStateInByteOrderMark, OFXMLParserStateOutsideTag, OFXMLParserStateTagOpened, OFXMLParserStateInProcessingInstruction, OFXMLParserStateInTagName, OFXMLParserStateInCloseTagName, OFXMLParserStateInTag, OFXMLParserStateInAttributeName, OFXMLParserStateExpectAttributeEqualSign, OFXMLParserStateExpectAttributeDelimiter, OFXMLParserStateInAttributeValue, OFXMLParserStateExpectTagClose, OFXMLParserStateExpectSpaceOrTagClose, OFXMLParserStateInExclamationMark, OFXMLParserStateInCDATAOpening, OFXMLParserStateInCDATA, OFXMLParserStateInCommentOpening, OFXMLParserStateInComment1, OFXMLParserStateInComment2, OFXMLParserStateInDOCTYPE } _state; size_t _i, _last; const char *_Nullable _data; OFMutableData *_buffer; OFString *_Nullable _name, *_Nullable _prefix; OFMutableArray OF_GENERIC(OFMutableDictionary OF_GENERIC(OFString *, OFString *) *) |
︙ | ︙ |
Modified src/OFXMLParser.m from [d9e7407eb2] to [d255848201].
︙ | ︙ | |||
61 62 63 64 65 66 67 | static void inCDATAState(OFXMLParser *); static void inCommentOpeningState(OFXMLParser *); static void inCommentState1(OFXMLParser *); static void inCommentState2(OFXMLParser *); static void inDOCTYPEState(OFXMLParser *); typedef void (*state_function_t)(OFXMLParser *); static state_function_t lookupTable[] = { | | | | > | | | | | < > < > | | | | | | | | | | | 61 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 92 93 94 95 96 97 | static void inCDATAState(OFXMLParser *); static void inCommentOpeningState(OFXMLParser *); static void inCommentState1(OFXMLParser *); static void inCommentState2(OFXMLParser *); static void inDOCTYPEState(OFXMLParser *); typedef void (*state_function_t)(OFXMLParser *); static state_function_t lookupTable[] = { [OFXMLParserStateInByteOrderMark] = inByteOrderMarkState, [OFXMLParserStateOutsideTag] = outsideTagState, [OFXMLParserStateTagOpened] = tagOpenedState, [OFXMLParserStateInProcessingInstruction] = inProcessingInstructionState, [OFXMLParserStateInTagName] = inTagNameState, [OFXMLParserStateInCloseTagName] = inCloseTagNameState, [OFXMLParserStateInTag] = inTagState, [OFXMLParserStateInAttributeName] = inAttributeNameState, [OFXMLParserStateExpectAttributeEqualSign] = expectAttributeEqualSignState, [OFXMLParserStateExpectAttributeDelimiter] = expectAttributeDelimiterState, [OFXMLParserStateInAttributeValue] = inAttributeValueState, [OFXMLParserStateExpectTagClose] = expectTagCloseState, [OFXMLParserStateExpectSpaceOrTagClose] = expectSpaceOrTagCloseState, [OFXMLParserStateInExclamationMark] = inExclamationMarkState, [OFXMLParserStateInCDATAOpening] = inCDATAOpeningState, [OFXMLParserStateInCDATA] = inCDATAState, [OFXMLParserStateInCommentOpening] = inCommentOpeningState, [OFXMLParserStateInComment1] = inCommentState1, [OFXMLParserStateInComment2] = inCommentState2, [OFXMLParserStateInDOCTYPE] = inDOCTYPEState }; static OF_INLINE void appendToBuffer(OFMutableData *buffer, const char *string, OFStringEncoding encoding, size_t length) { if OF_LIKELY(encoding == OFStringEncodingUTF8) |
︙ | ︙ | |||
253 254 255 256 257 258 259 | if (_data[_i] == '\r' || (_data[_i] == '\n' && !_lastCarriageReturn)) _lineNumber++; _lastCarriageReturn = (_data[_i] == '\r'); } | | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | if (_data[_i] == '\r' || (_data[_i] == '\n' && !_lastCarriageReturn)) _lineNumber++; _lastCarriageReturn = (_data[_i] == '\r'); } /* In OFXMLParserStateInTag, there can be only spaces */ if (length - _last > 0 && _state != OFXMLParserStateInTag) appendToBuffer(_buffer, _data + _last, _encoding, length - _last); } - (void)parseString: (OFString *)string { [self parseBuffer: string.UTF8String length: string.UTF8StringLength]; |
︙ | ︙ | |||
285 286 287 288 289 290 291 | } static void inByteOrderMarkState(OFXMLParser *self) { if (self->_data[self->_i] != "\xEF\xBB\xBF"[self->_level]) { if (self->_level == 0) { | | | | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | } static void inByteOrderMarkState(OFXMLParser *self) { if (self->_data[self->_i] != "\xEF\xBB\xBF"[self->_level]) { if (self->_level == 0) { self->_state = OFXMLParserStateOutsideTag; self->_i--; return; } @throw [OFMalformedXMLException exceptionWithParser: self]; } if (self->_level++ == 2) self->_state = OFXMLParserStateOutsideTag; self->_last = self->_i + 1; } /* Not in a tag */ static void outsideTagState(OFXMLParser *self) |
︙ | ︙ | |||
334 335 336 337 338 339 340 | objc_autoreleasePoolPop(pool); } [self->_buffer removeAllItems]; self->_last = self->_i + 1; | | | | | | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | objc_autoreleasePoolPop(pool); } [self->_buffer removeAllItems]; self->_last = self->_i + 1; self->_state = OFXMLParserStateTagOpened; } /* Tag was just opened */ static void tagOpenedState(OFXMLParser *self) { if (self->_finishedParsing && self->_data[self->_i] != '!' && self->_data[self->_i] != '?') @throw [OFMalformedXMLException exceptionWithParser: self]; switch (self->_data[self->_i]) { case '?': self->_last = self->_i + 1; self->_state = OFXMLParserStateInProcessingInstruction; self->_level = 0; break; case '/': self->_last = self->_i + 1; self->_state = OFXMLParserStateInCloseTagName; self->_acceptProlog = false; break; case '!': self->_last = self->_i + 1; self->_state = OFXMLParserStateInExclamationMark; self->_acceptProlog = false; break; default: if (self->_depthLimit > 0 && self->_previous.count >= self->_depthLimit) @throw [OFOutOfRangeException exception]; self->_state = OFXMLParserStateInTagName; self->_acceptProlog = false; self->_i--; break; } } /* <?xml […]?> */ |
︙ | ︙ | |||
511 512 513 514 515 516 517 | data: data]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; | | | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | data: data]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; self->_state = OFXMLParserStateOutsideTag; } else self->_level = 0; } /* Inside a tag, no name yet */ static void inTagNameState(OFXMLParser *self) |
︙ | ︙ | |||
589 590 591 592 593 594 595 | [self->_previous addObject: bufferString]; [self->_name release]; [self->_prefix release]; self->_name = self->_prefix = nil; self->_state = (self->_data[self->_i] == '/' | | | | | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | [self->_previous addObject: bufferString]; [self->_name release]; [self->_prefix release]; self->_name = self->_prefix = nil; self->_state = (self->_data[self->_i] == '/' ? OFXMLParserStateExpectTagClose : OFXMLParserStateOutsideTag); } else self->_state = OFXMLParserStateInTag; if (self->_data[self->_i] != '/') [self->_namespaces addObject: [OFMutableDictionary dictionary]]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; |
︙ | ︙ | |||
670 671 672 673 674 675 676 | [self->_namespaces removeLastObject]; [self->_name release]; [self->_prefix release]; self->_name = self->_prefix = nil; self->_last = self->_i + 1; self->_state = (self->_data[self->_i] == '>' | | | | | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | [self->_namespaces removeLastObject]; [self->_name release]; [self->_prefix release]; self->_name = self->_prefix = nil; self->_last = self->_i + 1; self->_state = (self->_data[self->_i] == '>' ? OFXMLParserStateOutsideTag : OFXMLParserStateExpectSpaceOrTagClose); if (self->_previous.count == 0) self->_finishedParsing = true; } /* Inside a tag, name found */ static void inTagState(OFXMLParser *self) { void *pool; OFString *namespace; OFXMLAttribute *const *attributesObjects; size_t attributesCount; if (self->_data[self->_i] != '>' && self->_data[self->_i] != '/') { if (self->_data[self->_i] != ' ' && self->_data[self->_i] != '\t' && self->_data[self->_i] != '\n' && self->_data[self->_i] != '\r') { self->_last = self->_i; self->_state = OFXMLParserStateInAttributeName; self->_i--; } return; } attributesObjects = self->_attributes.objects; |
︙ | ︙ | |||
751 752 753 754 755 756 757 | [self->_name release]; [self->_prefix release]; [self->_attributes removeAllObjects]; self->_name = self->_prefix = nil; self->_last = self->_i + 1; self->_state = (self->_data[self->_i] == '/' | | < | 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | [self->_name release]; [self->_prefix release]; [self->_attributes removeAllObjects]; self->_name = self->_prefix = nil; self->_last = self->_i + 1; self->_state = (self->_data[self->_i] == '/' ? OFXMLParserStateExpectTagClose : OFXMLParserStateOutsideTag); } /* Looking for attribute name */ static void inAttributeNameState(OFXMLParser *self) { void *pool; |
︙ | ︙ | |||
800 801 802 803 804 805 806 | objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; self->_state = (self->_data[self->_i] == '=' | | | | | 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; self->_state = (self->_data[self->_i] == '=' ? OFXMLParserStateExpectAttributeDelimiter : OFXMLParserStateExpectAttributeEqualSign); } /* Expecting equal sign of an attribute */ static void expectAttributeEqualSignState(OFXMLParser *self) { if (self->_data[self->_i] == '=') { self->_last = self->_i + 1; self->_state = OFXMLParserStateExpectAttributeDelimiter; return; } if (self->_data[self->_i] != ' ' && self->_data[self->_i] != '\t' && self->_data[self->_i] != '\n' && self->_data[self->_i] != '\r') @throw [OFMalformedXMLException exceptionWithParser: self]; } |
︙ | ︙ | |||
833 834 835 836 837 838 839 | self->_data[self->_i] == '\n' || self->_data[self->_i] == '\r') return; if (self->_data[self->_i] != '\'' && self->_data[self->_i] != '"') @throw [OFMalformedXMLException exceptionWithParser: self]; self->_delimiter = self->_data[self->_i]; | | | 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 | self->_data[self->_i] == '\n' || self->_data[self->_i] == '\r') return; if (self->_data[self->_i] != '\'' && self->_data[self->_i] != '"') @throw [OFMalformedXMLException exceptionWithParser: self]; self->_delimiter = self->_data[self->_i]; self->_state = OFXMLParserStateInAttributeValue; } /* Looking for attribute value */ static void inAttributeValueState(OFXMLParser *self) { void *pool; |
︙ | ︙ | |||
877 878 879 880 881 882 883 | [self->_buffer removeAllItems]; [self->_attributeName release]; [self->_attributePrefix release]; self->_attributeName = self->_attributePrefix = nil; self->_last = self->_i + 1; | | | | | | | | | 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | [self->_buffer removeAllItems]; [self->_attributeName release]; [self->_attributePrefix release]; self->_attributeName = self->_attributePrefix = nil; self->_last = self->_i + 1; self->_state = OFXMLParserStateInTag; } /* Expecting closing '>' */ static void expectTagCloseState(OFXMLParser *self) { if (self->_data[self->_i] == '>') { self->_last = self->_i + 1; self->_state = OFXMLParserStateOutsideTag; } else @throw [OFMalformedXMLException exceptionWithParser: self]; } /* Expecting closing '>' or space */ static void expectSpaceOrTagCloseState(OFXMLParser *self) { if (self->_data[self->_i] == '>') { self->_last = self->_i + 1; self->_state = OFXMLParserStateOutsideTag; } else if (self->_data[self->_i] != ' ' && self->_data[self->_i] != '\t' && self->_data[self->_i] != '\n' && self->_data[self->_i] != '\r') @throw [OFMalformedXMLException exceptionWithParser: self]; } /* In <! */ static void inExclamationMarkState(OFXMLParser *self) { if (self->_finishedParsing && self->_data[self->_i] != '-') @throw [OFMalformedXMLException exceptionWithParser: self]; if (self->_data[self->_i] == '-') self->_state = OFXMLParserStateInCommentOpening; else if (self->_data[self->_i] == '[') { self->_state = OFXMLParserStateInCDATAOpening; self->_level = 0; } else if (self->_data[self->_i] == 'D') { self->_state = OFXMLParserStateInDOCTYPE; self->_level = 0; } else @throw [OFMalformedXMLException exceptionWithParser: self]; self->_last = self->_i + 1; } /* CDATA */ static void inCDATAOpeningState(OFXMLParser *self) { if (self->_data[self->_i] != "CDATA["[self->_level]) @throw [OFMalformedXMLException exceptionWithParser: self]; if (++self->_level == 6) { self->_state = OFXMLParserStateInCDATA; self->_level = 0; } self->_last = self->_i + 1; } static void |
︙ | ︙ | |||
962 963 964 965 966 967 968 | [self->_delegate parser: self foundCDATA: CDATA]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; | | | | | 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | [self->_delegate parser: self foundCDATA: CDATA]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; self->_state = OFXMLParserStateOutsideTag; } else self->_level = 0; } /* Comment */ static void inCommentOpeningState(OFXMLParser *self) { if (self->_data[self->_i] != '-') @throw [OFMalformedXMLException exceptionWithParser: self]; self->_last = self->_i + 1; self->_state = OFXMLParserStateInComment1; self->_level = 0; } static void inCommentState1(OFXMLParser *self) { if (self->_data[self->_i] == '-') self->_level++; else self->_level = 0; if (self->_level == 2) self->_state = OFXMLParserStateInComment2; } static void inCommentState2(OFXMLParser *self) { void *pool; OFString *comment; |
︙ | ︙ | |||
1015 1016 1017 1018 1019 1020 1021 | [self->_delegate parser: self foundComment: comment]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; | | | | 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | [self->_delegate parser: self foundComment: comment]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; self->_last = self->_i + 1; self->_state = OFXMLParserStateOutsideTag; } /* In <!DOCTYPE ...> */ static void inDOCTYPEState(OFXMLParser *self) { if ((self->_level < 6 && self->_data[self->_i] != "OCTYPE"[self->_level]) || (self->_level == 6 && self->_data[self->_i] != ' ' && self->_data[self->_i] != '\t' && self->_data[self->_i] != '\n' && self->_data[self->_i] != '\r')) @throw [OFMalformedXMLException exceptionWithParser: self]; self->_level++; if (self->_level > 6 && self->_data[self->_i] == '>') self->_state = OFXMLParserStateOutsideTag; self->_last = self->_i + 1; } - (size_t)lineNumber { return _lineNumber; |
︙ | ︙ |
Modified src/OFZIPArchive.h from [6e903727fb] to [12eebcf96b].
︙ | ︙ | |||
31 32 33 34 35 36 37 | */ OF_SUBCLASSING_RESTRICTED @interface OFZIPArchive: OFObject { OFStream *_stream; int64_t _offset; enum { | | | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | */ OF_SUBCLASSING_RESTRICTED @interface OFZIPArchive: OFObject { OFStream *_stream; int64_t _offset; enum { OFZIPArchiveModeRead, OFZIPArchiveModeWrite, OFZIPArchiveModeAppend } _mode; uint32_t _diskNumber, _centralDirectoryDisk; uint64_t _centralDirectoryEntriesInDisk, _centralDirectoryEntries; uint64_t _centralDirectorySize; int64_t _centralDirectoryOffset; OFString *_Nullable _archiveComment; OFMutableArray OF_GENERIC(OFZIPArchiveEntry *) *_entries; |
︙ | ︙ |
Modified src/OFZIPArchive.m from [e83455a311] to [b583ae2e67].
︙ | ︙ | |||
99 100 101 102 103 104 105 | } - (instancetype)initWithStream: (OFStream *)stream entry: (OFMutableZIPArchiveEntry *)entry; @end uint32_t | | | | 99 100 101 102 103 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 | } - (instancetype)initWithStream: (OFStream *)stream entry: (OFMutableZIPArchiveEntry *)entry; @end uint32_t OFZIPArchiveReadField32(const uint8_t **data, uint16_t *size) { uint32_t field = 0; if (*size < 4) @throw [OFInvalidFormatException exception]; for (uint8_t i = 0; i < 4; i++) field |= (uint32_t)(*data)[i] << (i * 8); *data += 4; *size -= 4; return field; } uint64_t OFZIPArchiveReadField64(const uint8_t **data, uint16_t *size) { uint64_t field = 0; if (*size < 8) @throw [OFInvalidFormatException exception]; for (uint8_t i = 0; i < 8; i++) |
︙ | ︙ | |||
172 173 174 175 176 177 178 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { if ([mode isEqual: @"r"]) | | | | | | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { if ([mode isEqual: @"r"]) _mode = OFZIPArchiveModeRead; else if ([mode isEqual: @"w"]) _mode = OFZIPArchiveModeWrite; else if ([mode isEqual: @"a"]) _mode = OFZIPArchiveModeAppend; else @throw [OFInvalidArgumentException exception]; _stream = [stream retain]; _entries = [[OFMutableArray alloc] init]; _pathToEntryMap = [[OFMutableDictionary alloc] init]; if (_mode == OFZIPArchiveModeRead || _mode == OFZIPArchiveModeAppend) { if (![stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; [self of_readZIPInfo]; [self of_readEntries]; } if (_mode == OFZIPArchiveModeAppend) { _offset = _centralDirectoryOffset; seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (OFFileOffset)_offset, SEEK_SET); } } @catch (id e) { /* * If we are in write or append mode, we do not want -[close] |
︙ | ︙ | |||
397 398 399 400 401 402 403 | { @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } | | | | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | { @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } if ((_mode == OFZIPArchiveModeWrite || _mode == OFZIPArchiveModeAppend) && [_lastReturnedStream isKindOfClass: [OFZIPArchiveFileWriteStream class]]) { OFZIPArchiveFileWriteStream *stream = (OFZIPArchiveFileWriteStream *)_lastReturnedStream; if (INT64_MAX - _offset < stream->_bytesWritten) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
427 428 429 430 431 432 433 | - (OFStream *)streamForReadingFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFZIPArchiveEntry *entry; OFZIPArchiveLocalFileHeader *localFileHeader; int64_t offset64; | | | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | - (OFStream *)streamForReadingFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFZIPArchiveEntry *entry; OFZIPArchiveLocalFileHeader *localFileHeader; int64_t offset64; if (_mode != OFZIPArchiveModeRead) @throw [OFInvalidArgumentException exception]; if ((entry = [_pathToEntryMap objectForKey: path]) == nil) @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" errNo: ENOENT]; |
︙ | ︙ | |||
477 478 479 480 481 482 483 | int64_t offsetAdd = 0; void *pool; OFMutableZIPArchiveEntry *entry; OFString *fileName; OFData *extraField; uint16_t fileNameLength, extraFieldLength; | | < | < | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | int64_t offsetAdd = 0; void *pool; OFMutableZIPArchiveEntry *entry; OFString *fileName; OFData *extraField; uint16_t fileNameLength, extraFieldLength; if (_mode != OFZIPArchiveModeWrite && _mode != OFZIPArchiveModeAppend) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); entry = [[entry_ mutableCopy] autorelease]; if ([_pathToEntryMap objectForKey: entry.fileName] != nil) @throw [OFOpenItemFailedException exceptionWithPath: entry.fileName mode: @"w" errNo: EEXIST]; if (entry.compressionMethod != OFZIPArchiveEntryCompressionMethodNone) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; [self of_closeLastReturnedStream]; fileName = entry.fileName; fileNameLength = fileName.UTF8StringLength; |
︙ | ︙ | |||
531 532 533 534 535 536 537 | [_stream writeLittleEndianInt16: fileNameLength]; [_stream writeLittleEndianInt16: extraFieldLength + 20]; offsetAdd += 4 + (5 * 2) + (3 * 4) + (2 * 2); [_stream writeString: fileName]; offsetAdd += fileNameLength; | | < | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | [_stream writeLittleEndianInt16: fileNameLength]; [_stream writeLittleEndianInt16: extraFieldLength + 20]; offsetAdd += 4 + (5 * 2) + (3 * 4) + (2 * 2); [_stream writeString: fileName]; offsetAdd += fileNameLength; [_stream writeLittleEndianInt16: OFZIPArchiveEntryExtraFieldTagZIP64]; [_stream writeLittleEndianInt16: 16]; /* We use the data descriptor */ [_stream writeLittleEndianInt64: 0]; [_stream writeLittleEndianInt64: 0]; offsetAdd += (2 * 2) + (2 * 8); if (extraField != nil) |
︙ | ︙ | |||
613 614 615 616 617 618 619 | - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; [self of_closeLastReturnedStream]; | | < | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; [self of_closeLastReturnedStream]; if (_mode == OFZIPArchiveModeWrite || _mode == OFZIPArchiveModeAppend) [self of_writeCentralDirectory]; [_stream release]; _stream = nil; } @end |
︙ | ︙ | |||
657 658 659 660 661 662 663 | _fileName = [[stream readStringWithLength: fileNameLength encoding: encoding] copy]; if (extraFieldLength > 0) extraField = [[[stream readDataWithCount: extraFieldLength] mutableCopy] autorelease]; | | | | | | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | _fileName = [[stream readStringWithLength: fileNameLength encoding: encoding] copy]; if (extraFieldLength > 0) extraField = [[[stream readDataWithCount: extraFieldLength] mutableCopy] autorelease]; ZIP64Index = OFZIPArchiveEntryExtraFieldFind(extraField, OFZIPArchiveEntryExtraFieldTagZIP64, &ZIP64Size); if (ZIP64Index != OFNotFound) { const uint8_t *ZIP64 = [extraField itemAtIndex: ZIP64Index]; OFRange range = OFRangeMake(ZIP64Index - 4, ZIP64Size + 4); if (_uncompressedSize == 0xFFFFFFFF) _uncompressedSize = OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (_compressedSize == 0xFFFFFFFF) _compressedSize = OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (ZIP64Size > 0) @throw [OFInvalidFormatException exception]; [extraField removeItemsInRange: range]; } |
︙ | ︙ | |||
731 732 733 734 735 736 737 | { self = [super init]; @try { _stream = [stream retain]; switch (entry.compressionMethod) { | | | | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | { self = [super init]; @try { _stream = [stream retain]; switch (entry.compressionMethod) { case OFZIPArchiveEntryCompressionMethodNone: _decompressedStream = [stream retain]; break; case OFZIPArchiveEntryCompressionMethodDeflate: _decompressedStream = [[OFInflateStream alloc] initWithStream: stream]; break; case OFZIPArchiveEntryCompressionMethodDeflate64: _decompressedStream = [[OFInflate64Stream alloc] initWithStream: stream]; break; default: @throw [OFNotImplementedException exceptionWithSelector: _cmd object: nil]; |
︙ | ︙ |
Modified src/OFZIPArchiveEntry.h from [3bbdaa40a9] to [79b0008ba2].
︙ | ︙ | |||
15 16 17 18 19 20 21 | #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** @file */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | > | < > > > | | | 15 16 17 18 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 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** @file */ typedef enum OFZIPArchiveEntryCompressionMethod { OFZIPArchiveEntryCompressionMethodNone = 0, OFZIPArchiveEntryCompressionMethodShrink = 1, OFZIPArchiveEntryCompressionMethodReduceFactor1 = 2, OFZIPArchiveEntryCompressionMethodReduceFactor2 = 3, OFZIPArchiveEntryCompressionMethodReduceFactor3 = 4, OFZIPArchiveEntryCompressionMethodReduceFactor4 = 5, OFZIPArchiveEntryCompressionMethodImplode = 6, OFZIPArchiveEntryCompressionMethodDeflate = 8, OFZIPArchiveEntryCompressionMethodDeflate64 = 9, OFZIPArchiveEntryCompressionMethodBZIP2 = 12, OFZIPArchiveEntryCompressionMethodLZMA = 14, OFZIPArchiveEntryCompressionMethodWavPack = 97, OFZIPArchiveEntryCompressionMethodPPMd = 98 } OFZIPArchiveEntryCompressionMethod; /** * @brief Attribute compatibility part of ZIP versions. */ typedef enum OFZIPArchiveEntryAttributeCompatibility { /** MS-DOS and OS/2 */ OFZIPArchiveEntryAttributeCompatibilityMSDOS = 0, /** Amiga */ OFZIPArchiveEntryAttributeCompatibilityAmiga = 1, /** OpenVMS */ OFZIPArchiveEntryAttributeCompatibilityOpenVMS = 2, /** UNIX */ OFZIPArchiveEntryAttributeCompatibilityUNIX = 3, /** VM/CMS */ OFZIPArchiveEntryAttributeCompatibilityVM_CMS = 4, /** Atari ST */ OFZIPArchiveEntryAttributeCompatibilityAtariST = 5, /** OS/2 HPFS */ OFZIPArchiveEntryAttributeCompatibilityOS2HPFS = 6, /** Macintosh */ OFZIPArchiveEntryAttributeCompatibilityMacintosh = 7, /** Z-System */ OFZIPArchiveEntryAttributeCompatibilityZSystem = 8, /** CP/M */ OFZIPArchiveEntryAttributeCompatibilityCPM = 9, /** Windows NTFS */ OFZIPArchiveEntryAttributeCompatibilityWindowsNTFS = 10, /** MVS (OS/390 - Z/OS) */ OFZIPArchiveEntryAttributeCompatibilityMVS = 11, /** VSE */ OFZIPArchiveEntryAttributeCompatibilityVSE = 12, /** Acorn RISC OS */ OFZIPArchiveEntryAttributeCompatibilityAcornRISCOS = 13, /** VFAT */ OFZIPArchiveEntryAttributeCompatibilityVFAT = 14, /** Alternate MVS */ OFZIPArchiveEntryAttributeCompatibilityAlternateMVS = 15, /** BeOS */ OFZIPArchiveEntryAttributeCompatibilityBeOS = 16, /** Tandem */ OFZIPArchiveEntryAttributeCompatibilityTandem = 17, /** OS/400 */ OFZIPArchiveEntryAttributeCompatibilityOS400 = 18, /** OS X (Darwin) */ OFZIPArchiveEntryAttributeCompatibilityOSX = 19 } OFZIPArchiveEntryAttributeCompatibility; /** * @brief Tags for the extra field. */ typedef enum OFZIPArchiveEntryExtraFieldTag { /** ZIP64 extra field tag */ OFZIPArchiveEntryExtraFieldTagZIP64 = 0x0001 } OFZIPArchiveEntryExtraFieldTag; @class OFString; @class OFData; @class OFFile; @class OFDate; /** * @class OFZIPArchiveEntry OFZIPArchiveEntry.h ObjFW/OFZIPArchiveEntry.h * * @brief A class which represents an entry in the central directory of a ZIP * archive. */ @interface OFZIPArchiveEntry: OFObject <OFCopying, OFMutableCopying> { OFZIPArchiveEntryAttributeCompatibility _versionMadeBy; OFZIPArchiveEntryAttributeCompatibility _minVersionNeeded; uint16_t _generalPurposeBitFlag; OFZIPArchiveEntryCompressionMethod _compressionMethod; uint16_t _lastModifiedFileTime, _lastModifiedFileDate; uint32_t _CRC32; uint64_t _compressedSize, _uncompressedSize; OFString *_fileName; OFData *_Nullable _extraField; OFString *_Nullable _fileComment; uint32_t _startDiskNumber; |
︙ | ︙ | |||
132 133 134 135 136 137 138 | @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFData *extraField; /** * @brief The version which made the entry. * * The lower 8 bits are the ZIP specification version.@n * The upper 8 bits are the attribute compatibility. | | | > | | > | | | | | | > | 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 182 183 184 185 186 187 | @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFData *extraField; /** * @brief The version which made the entry. * * The lower 8 bits are the ZIP specification version.@n * The upper 8 bits are the attribute compatibility. * See @ref OFZIPArchiveEntryAttributeCompatibility. */ @property (readonly, nonatomic) OFZIPArchiveEntryAttributeCompatibility versionMadeBy; /** * @brief The minimum version required to extract the file. * * The lower 8 bits are the ZIP specification version.@n * The upper 8 bits are the attribute compatibility. * See @ref OFZIPArchiveEntryAttributeCompatibility. */ @property (readonly, nonatomic) OFZIPArchiveEntryAttributeCompatibility minVersionNeeded; /** * @brief The last modification date of the entry's file. * * @note Due to limitations of the ZIP format, this has only 2 second precision. */ @property (readonly, retain, nonatomic) OFDate *modificationDate; /** * @brief The compression method of the entry. * * Supported values are: * Value | Description * --------------------------------------------|--------------- * OFZIPArchiveEntryCompressionMethodNone | No compression * OFZIPArchiveEntryCompressionMethodDeflate | Deflate * OFZIPArchiveEntryCompressionMethodDeflate64 | Deflate64 * * Other values may be returned, but the file cannot be extracted then. */ @property (readonly, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; /** * @brief The compressed size of the entry's file. */ @property (readonly, nonatomic) uint64_t compressedSize; /** |
︙ | ︙ | |||
225 226 227 228 229 230 231 | #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 */ | | | | | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | #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 *OFZIPArchiveEntryVersionToString(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 *OFZIPArchiveEntryCompressionMethodName( OFZIPArchiveEntryCompressionMethod 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 * @param size A pointer to an uint16_t that should be set to the size * @return The index at which the extra field content starts in the OFData, or * `OFNotFound` */ extern size_t OFZIPArchiveEntryExtraFieldFind(OFData *extraField, OFZIPArchiveEntryExtraFieldTag tag, uint16_t *size); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #import "OFMutableZIPArchiveEntry.h" |
Modified src/OFZIPArchiveEntry.m from [4136550749] to [4408bc6ea7].
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OFStream.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | 22 23 24 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 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 153 154 155 | #import "OFStream.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" extern uint32_t OFZIPArchiveReadField32(const uint8_t **, uint16_t *); extern uint64_t OFZIPArchiveReadField64(const uint8_t **, uint16_t *); OFString * OFZIPArchiveEntryVersionToString(uint16_t version) { const char *attrCompat = NULL; switch (version >> 8) { case OFZIPArchiveEntryAttributeCompatibilityMSDOS: attrCompat = "MS-DOS or OS/2"; break; case OFZIPArchiveEntryAttributeCompatibilityAmiga: attrCompat = "Amiga"; break; case OFZIPArchiveEntryAttributeCompatibilityOpenVMS: attrCompat = "OpenVMS"; break; case OFZIPArchiveEntryAttributeCompatibilityUNIX: attrCompat = "UNIX"; break; case OFZIPArchiveEntryAttributeCompatibilityVM_CMS: attrCompat = "VM/CMS"; break; case OFZIPArchiveEntryAttributeCompatibilityAtariST: attrCompat = "Atari ST"; break; case OFZIPArchiveEntryAttributeCompatibilityOS2HPFS: attrCompat = "OS/2 HPFS"; break; case OFZIPArchiveEntryAttributeCompatibilityMacintosh: attrCompat = "Macintosh"; break; case OFZIPArchiveEntryAttributeCompatibilityZSystem: attrCompat = "Z-System"; break; case OFZIPArchiveEntryAttributeCompatibilityCPM: attrCompat = "CP/M"; break; case OFZIPArchiveEntryAttributeCompatibilityWindowsNTFS: attrCompat = "Windows NTFS"; break; case OFZIPArchiveEntryAttributeCompatibilityMVS: attrCompat = "MVS (OS/390 - Z/OS)"; break; case OFZIPArchiveEntryAttributeCompatibilityVSE: attrCompat = "VSE"; break; case OFZIPArchiveEntryAttributeCompatibilityAcornRISCOS: attrCompat = "Acorn RISC OS"; break; case OFZIPArchiveEntryAttributeCompatibilityVFAT: attrCompat = "VFAT"; break; case OFZIPArchiveEntryAttributeCompatibilityAlternateMVS: attrCompat = "Alternate MVS"; break; case OFZIPArchiveEntryAttributeCompatibilityBeOS: attrCompat = "BeOS"; break; case OFZIPArchiveEntryAttributeCompatibilityTandem: attrCompat = "Tandem"; break; case OFZIPArchiveEntryAttributeCompatibilityOS400: attrCompat = "OS/400"; break; case OFZIPArchiveEntryAttributeCompatibilityOSX: attrCompat = "OS X (Darwin)"; break; } if (attrCompat != NULL) return [OFString stringWithFormat: @"%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 * OFZIPArchiveEntryCompressionMethodName( OFZIPArchiveEntryCompressionMethod compressionMethod) { switch (compressionMethod) { case OFZIPArchiveEntryCompressionMethodNone: return @"none"; case OFZIPArchiveEntryCompressionMethodShrink: return @"Shrink"; case OFZIPArchiveEntryCompressionMethodReduceFactor1: return @"Reduce (factor 1)"; case OFZIPArchiveEntryCompressionMethodReduceFactor2: return @"Reduce (factor 2)"; case OFZIPArchiveEntryCompressionMethodReduceFactor3: return @"Reduce (factor 3)"; case OFZIPArchiveEntryCompressionMethodReduceFactor4: return @"Reduce (factor 4)"; case OFZIPArchiveEntryCompressionMethodImplode: return @"Implode"; case OFZIPArchiveEntryCompressionMethodDeflate: return @"Deflate"; case OFZIPArchiveEntryCompressionMethodDeflate64: return @"Deflate64"; case OFZIPArchiveEntryCompressionMethodBZIP2: return @"BZip2"; case OFZIPArchiveEntryCompressionMethodLZMA: return @"LZMA"; case OFZIPArchiveEntryCompressionMethodWavPack: return @"WavPack"; case OFZIPArchiveEntryCompressionMethodPPMd: return @"PPMd"; default: return @"unknown"; } } size_t OFZIPArchiveEntryExtraFieldFind(OFData *extraField, OFZIPArchiveEntryExtraFieldTag tag, uint16_t *size) { const uint8_t *bytes = extraField.items; size_t count = extraField.count; for (size_t i = 0; i < count;) { uint16_t currentTag, currentSize; |
︙ | ︙ | |||
246 247 248 249 250 251 252 | extraField = [[[stream readDataWithCount: extraFieldLength] mutableCopy] autorelease]; if (fileCommentLength > 0) _fileComment = [[stream readStringWithLength: fileCommentLength encoding: encoding] copy]; | | | | | < | | | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | extraField = [[[stream readDataWithCount: extraFieldLength] mutableCopy] autorelease]; if (fileCommentLength > 0) _fileComment = [[stream readStringWithLength: fileCommentLength encoding: encoding] copy]; ZIP64Index = OFZIPArchiveEntryExtraFieldFind(extraField, OFZIPArchiveEntryExtraFieldTagZIP64, &ZIP64Size); if (ZIP64Index != OFNotFound) { const uint8_t *ZIP64 = [extraField itemAtIndex: ZIP64Index]; OFRange range = OFRangeMake(ZIP64Index - 4, ZIP64Size + 4); if (_uncompressedSize == 0xFFFFFFFF) _uncompressedSize = OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (_compressedSize == 0xFFFFFFFF) _compressedSize = OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (_localFileHeaderOffset == 0xFFFFFFFF) _localFileHeaderOffset = OFZIPArchiveReadField64(&ZIP64, &ZIP64Size); if (_startDiskNumber == 0xFFFF) _startDiskNumber = OFZIPArchiveReadField32( &ZIP64, &ZIP64Size); if (ZIP64Size > 0 || _localFileHeaderOffset < 0) @throw [OFInvalidFormatException exception]; [extraField removeItemsInRange: range]; } |
︙ | ︙ | |||
347 348 349 350 351 352 353 | } - (OFData *)extraField { return _extraField; } | | | | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | } - (OFData *)extraField { return _extraField; } - (OFZIPArchiveEntryAttributeCompatibility)versionMadeBy { return _versionMadeBy; } - (OFZIPArchiveEntryAttributeCompatibility)minVersionNeeded { return _minVersionNeeded; } - (OFDate *)modificationDate { void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
381 382 383 384 385 386 387 | format: @"%Y-%m-%d %H:%M:%S"]; objc_autoreleasePoolPop(pool); return [date autorelease]; } | | | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | format: @"%Y-%m-%d %H:%M:%S"]; objc_autoreleasePoolPop(pool); return [date autorelease]; } - (OFZIPArchiveEntryCompressionMethod)compressionMethod { return _compressionMethod; } - (uint64_t)compressedSize { return _compressedSize; |
︙ | ︙ | |||
430 431 432 433 434 435 436 | return _localFileHeaderOffset; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *compressionMethod = | < | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | return _localFileHeaderOffset; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *compressionMethod = OFZIPArchiveEntryCompressionMethodName(_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" |
︙ | ︙ | |||
486 487 488 489 490 491 492 | [stream writeLittleEndianInt32: _versionSpecificAttributes]; [stream writeLittleEndianInt32: 0xFFFFFFFF]; size += (4 + (6 * 2) + (3 * 4) + (5 * 2) + (2 * 4)); [stream writeString: _fileName]; size += (uint64_t)_fileName.UTF8StringLength; | | | 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | [stream writeLittleEndianInt32: _versionSpecificAttributes]; [stream writeLittleEndianInt32: 0xFFFFFFFF]; size += (4 + (6 * 2) + (3 * 4) + (5 * 2) + (2 * 4)); [stream writeString: _fileName]; size += (uint64_t)_fileName.UTF8StringLength; [stream writeLittleEndianInt16: OFZIPArchiveEntryExtraFieldTagZIP64]; [stream writeLittleEndianInt16: 28]; [stream writeLittleEndianInt64: _uncompressedSize]; [stream writeLittleEndianInt64: _compressedSize]; [stream writeLittleEndianInt64: _localFileHeaderOffset]; [stream writeLittleEndianInt32: _startDiskNumber]; size += (2 * 2) + (3 * 8) + 4; |
︙ | ︙ |
Modified utils/ofarc/ZIPArchive.m from [20066e086c] to [2b6d39166d].
︙ | ︙ | |||
37 38 39 40 41 42 43 | static OFArc *app; static void setPermissions(OFString *path, OFZIPArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS if ((entry.versionMadeBy >> 8) == | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | static OFArc *app; static void setPermissions(OFString *path, OFZIPArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS if ((entry.versionMadeBy >> 8) == OFZIPArchiveEntryAttributeCompatibilityUNIX) { OFNumber *mode = [OFNumber numberWithUnsignedShort: (entry.versionSpecificAttributes >> 16) & 0777]; OFFileAttributes attributes = [OFDictionary dictionaryWithObject: mode forKey: OFFilePOSIXPermissions]; [[OFFileManager defaultManager] setAttributes: attributes |
︙ | ︙ | |||
121 122 123 124 125 126 127 | OFString *compressedSize = [OFString stringWithFormat: @"%" PRIu64, entry.compressedSize]; OFString *uncompressedSize = [OFString stringWithFormat: @"%" PRIu64, entry.uncompressedSize]; OFString *compressionMethod = | | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | OFString *compressedSize = [OFString stringWithFormat: @"%" PRIu64, entry.compressedSize]; OFString *uncompressedSize = [OFString stringWithFormat: @"%" PRIu64, entry.uncompressedSize]; OFString *compressionMethod = OFZIPArchiveEntryCompressionMethodName( 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"]; |
︙ | ︙ | |||
167 168 169 170 171 172 173 174 175 176 177 178 179 | [of_stdout writeLine: OF_LOCALIZED( @"list_modification_date", @"Modification date: %[date]", @"date", modificationDate)]; if (app->_outputLevel >= 2) { uint16_t versionMadeBy = entry.versionMadeBy; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_version_made_by", @"Version made by: %[version]", @"version", | > > | | | < | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | [of_stdout writeLine: OF_LOCALIZED( @"list_modification_date", @"Modification date: %[date]", @"date", modificationDate)]; if (app->_outputLevel >= 2) { uint16_t versionMadeBy = entry.versionMadeBy; OFZIPArchiveEntryAttributeCompatibility UNIX = OFZIPArchiveEntryAttributeCompatibilityUNIX; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_version_made_by", @"Version made by: %[version]", @"version", OFZIPArchiveEntryVersionToString( versionMadeBy))]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_min_version_needed", @"Minimum version needed: %[version]", @"version", OFZIPArchiveEntryVersionToString( entry.minVersionNeeded))]; if ((versionMadeBy >> 8) == UNIX) { uint32_t mode = entry .versionSpecificAttributes >> 16; OFString *modeString = [OFString stringWithFormat: @"%06o", mode]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_mode", |
︙ | ︙ | |||
441 442 443 444 445 446 447 | if (size > INT64_MAX) @throw [OFOutOfRangeException exception]; entry.compressedSize = (int64_t)size; entry.uncompressedSize = (int64_t)size; entry.compressionMethod = | | | 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | if (size > INT64_MAX) @throw [OFOutOfRangeException exception]; entry.compressedSize = (int64_t)size; entry.uncompressedSize = (int64_t)size; entry.compressionMethod = OFZIPArchiveEntryCompressionMethodNone; entry.modificationDate = attributes.fileModificationDate; [entry makeImmutable]; output = [_archive streamForWritingEntry: entry]; if (!isDirectory) { |
︙ | ︙ |