Overview
Comment: | OFTarArchive: Clean up types |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fc6334102848bc5f3b6e248579b7af5a |
User & Date: | js on 2022-08-27 20:42:20 |
Other Links: | manifest | tags |
Context
2022-08-27
| ||
20:46 | OFZIPArchive: Restore accidentally dropped cast check-in: 6ae6830243 user: js tags: trunk | |
20:42 | OFTarArchive: Clean up types check-in: fc63341028 user: js tags: trunk | |
20:39 | Rename OFFileOffset -> OFStreamOffset check-in: 51589c6496 user: js tags: trunk | |
Changes
Modified src/OFTarArchive.m from [d41a5109d6] to [acb7a099c2].
︙ | ︙ | |||
33 34 35 36 37 38 39 | #import "OFWriteFailedException.h" OF_DIRECT_MEMBERS @interface OFTarArchiveFileReadStream: OFStream <OFReadyForReadingObserving> { OFTarArchiveEntry *_entry; OFStream *_stream; | | | | 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 | #import "OFWriteFailedException.h" OF_DIRECT_MEMBERS @interface OFTarArchiveFileReadStream: OFStream <OFReadyForReadingObserving> { OFTarArchiveEntry *_entry; OFStream *_stream; unsigned long long _toRead; bool _atEndOfStream, _skipped; } - (instancetype)of_initWithStream: (OFStream *)stream entry: (OFTarArchiveEntry *)entry; - (void)of_skip; @end OF_DIRECT_MEMBERS @interface OFTarArchiveFileWriteStream: OFStream <OFReadyForWritingObserving> { OFTarArchiveEntry *_entry; OFStream *_stream; unsigned long long _toWrite; } - (instancetype)of_initWithStream: (OFStream *)stream entry: (OFTarArchiveEntry *)entry; @end @implementation OFTarArchive: OFObject |
︙ | ︙ | |||
300 301 302 303 304 305 306 | if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; | | | | | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; #if SIZE_MAX >= ULLONG_MAX if (length > ULLONG_MAX) @throw [OFOutOfRangeException exception]; #endif if ((unsigned long long)length > _toRead) length = (size_t)_toRead; ret = [_stream readIntoBuffer: buffer length: length]; if (ret == 0) _atEndOfStream = true; _toRead -= ret; |
︙ | ︙ | |||
355 356 357 358 359 360 361 | - (void)of_skip { if (_stream == nil || _skipped) return; if ([_stream isKindOfClass: [OFSeekableStream class]] && | | | | | | 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 382 383 384 385 386 387 | - (void)of_skip { if (_stream == nil || _skipped) return; if ([_stream isKindOfClass: [OFSeekableStream class]] && _toRead <= LLONG_MAX && (OFStreamOffset)_toRead == (long long)_toRead) { unsigned long long size; [(OFSeekableStream *)_stream seekToOffset: (OFStreamOffset)_toRead whence: SEEK_CUR]; _toRead = 0; size = _entry.size; if (size % 512 != 0) [(OFSeekableStream *)_stream seekToOffset: 512 - (size % 512) whence: SEEK_CUR]; } else { char buffer[512]; unsigned long long size; while (_toRead >= 512) { [_stream readIntoBuffer: buffer exactLength: 512]; _toRead -= 512; } if (_toRead > 0) { |
︙ | ︙ | |||
430 431 432 433 434 435 436 | } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; | | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (length > _toWrite) @throw [OFOutOfRangeException exception]; @try { [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); |
︙ | ︙ | |||
467 468 469 470 471 472 473 | { return ((id <OFReadyForWritingObserving>)_stream) .fileDescriptorForWriting; } - (void)close { | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | { return ((id <OFReadyForWritingObserving>)_stream) .fileDescriptorForWriting; } - (void)close { unsigned long long remainder; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_toWrite > 0) @throw [OFTruncatedDataException exception]; |
︙ | ︙ |