Overview
Comment: | OFTarArchive: More efficient skipping
If the stream is seekable, seek instead of reading to skip. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
29ee511f5679384d55fdf5abae820331 |
User & Date: | js on 2017-08-07 00:20:35 |
Other Links: | manifest | tags |
Context
2017-08-07
| ||
22:41 | ofzip: Support for creating / appending ZIP files check-in: 0bb835712a user: js tags: trunk | |
00:20 | OFTarArchive: More efficient skipping check-in: 29ee511f56 user: js tags: trunk | |
2017-08-06
| ||
22:24 | ofzip: Include UID & GID in tar archives check-in: dc0a020230 user: js tags: trunk | |
Changes
Modified src/OFTarArchive.m from [794d54862e] to [944c9a1051].
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include "config.h" #import "OFTarArchive.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFStream.h" #import "OFDate.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFWriteFailedException.h" @interface OFTarArchive_FileReadStream: OFStream { OFTarArchiveEntry *_entry; | > | | 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 | #include "config.h" #import "OFTarArchive.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFStream.h" #import "OFSeekableStream.h" #import "OFDate.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFWriteFailedException.h" @interface OFTarArchive_FileReadStream: OFStream { OFTarArchiveEntry *_entry; OF_KINDOF(OFStream *) _stream; uint64_t _toRead; bool _atEndOfStream; } - initWithStream: (OFStream *)stream entry: (OFTarArchiveEntry *)entry; - (void)of_skip; |
︙ | ︙ | |||
336 337 338 339 340 341 342 | _stream = nil; [super close]; } - (void)of_skip { | > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | > | 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 382 383 384 385 386 | _stream = nil; [super close]; } - (void)of_skip { if ([_stream isKindOfClass: [OFSeekableStream class]] && _toRead <= INT64_MAX && (of_offset_t)_toRead == (int64_t)_toRead) { uint64_t size; [_stream seekToOffset: (of_offset_t)_toRead whence: SEEK_CUR]; _toRead = 0; size = [_entry size]; if (size % 512 != 0) [_stream seekToOffset: 512 - (size % 512) whence: SEEK_CUR]; } else { char buffer[512]; uint64_t size; while (_toRead >= 512) { [_stream readIntoBuffer: buffer exactLength: 512]; _toRead -= 512; } if (_toRead > 0) { [_stream readIntoBuffer: buffer exactLength: (size_t)_toRead]; _toRead = 0; } size = [_entry size]; if (size % 512 != 0) [_stream readIntoBuffer: buffer exactLength: 512 - (size % 512)]; } } @end @implementation OFTarArchive_FileWriteStream - initWithStream: (OFStream *)stream entry: (OFTarArchiveEntry *)entry { |
︙ | ︙ |