Overview
Comment: | OFLHAArchive: Properly zero-terminate archives |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
413965aa27b7028a2246a57d7cd8be50 |
User & Date: | js on 2024-02-26 20:09:09 |
Other Links: | manifest | tags |
Context
2024-02-26
| ||
20:32 | Use <cet.h> and _CET_ENDBR macro check-in: 0b441e52d6 user: js tags: trunk | |
20:09 | OFLHAArchive: Properly zero-terminate archives check-in: 4fbf5837fd user: js tags: 1.0 | |
20:09 | OFLHAArchive: Properly zero-terminate archives check-in: 413965aa27 user: js tags: trunk | |
2024-02-25
| ||
21:19 | OFLHAArchiveEntry: Create more compatible archives check-in: 7752f8518b user: js tags: trunk | |
Changes
Modified src/OFLHAArchive.h from [ef6819705d] to [2133fbb8dd].
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | uint_least8_t _mode; OFStringEncoding _encoding; OFLHAArchiveEntry *_Nullable _currentEntry; #ifdef OF_LHA_ARCHIVE_M @public #endif OFStream *_Nullable _lastReturnedStream; } /** * @brief The encoding to use for the archive. Defaults to ISO 8859-1. */ @property (nonatomic) OFStringEncoding encoding; | > > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | uint_least8_t _mode; OFStringEncoding _encoding; OFLHAArchiveEntry *_Nullable _currentEntry; #ifdef OF_LHA_ARCHIVE_M @public #endif OFStream *_Nullable _lastReturnedStream; @protected bool _hasWritten; } /** * @brief The encoding to use for the archive. Defaults to ISO 8859-1. */ @property (nonatomic) OFStringEncoding encoding; |
︙ | ︙ |
Modified src/OFLHAArchive.m from [f4f3dda99f] to [7a342795be].
︙ | ︙ | |||
121 122 123 124 125 126 127 | @throw [OFInvalidArgumentException exception]; if ((_mode == modeWrite || _mode == modeAppend) && ![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; if (_mode == modeAppend) | > > > > > > | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | @throw [OFInvalidArgumentException exception]; if ((_mode == modeWrite || _mode == modeAppend) && ![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; if (_mode == modeAppend) /* * Only works with properly zero-terminated files that * have no trailing garbage. Unfortunately there is no * good way to check for this other than reading the * entire archive. */ [(OFSeekableStream *)_stream seekToOffset: -1 whence: OFSeekEnd]; _encoding = OFStringEncodingISO8859_1; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | _lastReturnedStream = nil; _lastReturnedStream = [[[OFLHAArchiveFileWriteStream alloc] of_initWithArchive: self stream: (OFSeekableStream *)_stream entry: entry encoding: _encoding] autorelease]; return _lastReturnedStream; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { | > | > > > > > | 280 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 312 313 | _lastReturnedStream = nil; _lastReturnedStream = [[[OFLHAArchiveFileWriteStream alloc] of_initWithArchive: self stream: (OFSeekableStream *)_stream entry: entry encoding: _encoding] autorelease]; _hasWritten = true; return _lastReturnedStream; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine */ } /* LHA archives should be terminated with a header of size 0 */ if (_hasWritten) [_stream writeBuffer: "" length: 1]; _lastReturnedStream = nil; [_stream release]; _stream = nil; } @end |
︙ | ︙ |