Overview
Comment: | Fix OFSeekableStream.
-[seekToOffset:whence:] now works correctly when whence is SEEK_CUR. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d101b6f8b492e720f5f25be7ef8a8bb6 |
User & Date: | js on 2013-08-12 13:26:40 |
Other Links: | manifest | tags |
Context
2013-08-12
| ||
21:59 | OFZIPArchive: Initial implementation. check-in: 1c78b3a4db user: js tags: trunk | |
13:26 | Fix OFSeekableStream. check-in: d101b6f8b4 user: js tags: trunk | |
10:09 | Add codepage 437. check-in: 3912669d91 user: js tags: trunk | |
Changes
Modified src/OFFile.m from [bace7b9989] to [f060fd2dab].
︙ | ︙ | |||
767 768 769 770 771 772 773 | length: (size_t)length { if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length) @throw [OFWriteFailedException exceptionWithStream: self requestedLength: length]; } | | | | > > > > | 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 | length: (size_t)length { if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length) @throw [OFWriteFailedException exceptionWithStream: self requestedLength: length]; } - (off_t)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { off_t ret = lseek(_fd, offset, whence); if (ret == -1) @throw [OFSeekFailedException exceptionWithStream: self offset: offset whence: whence]; return ret; } - (int)fileDescriptorForReading { return _fd; } |
︙ | ︙ |
Modified src/OFSeekableStream.h from [4e7f25597b] to [ffc868cdea].
︙ | ︙ | |||
42 43 44 45 46 47 48 49 | * @param whence From where to seek.@n * Possible values are: * Value | Description * ---------|--------------------------------------- * SEEK_SET | Seek to the specified byte * SEEK_CUR | Seek to the current location + offset * SEEK_END | Seek to the end of the stream + offset */ | > | | > | | | 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 | * @param whence From where to seek.@n * Possible values are: * Value | Description * ---------|--------------------------------------- * SEEK_SET | Seek to the specified byte * SEEK_CUR | Seek to the current location + offset * SEEK_END | Seek to the end of the stream + offset * @return The new offset form the start of the file */ - (off_t)seekToOffset: (off_t)offset whence: (int)whence; /*! * @brief Seek the stream on the lowlevel. * * @warning Do not call this directly! * * Override this with this method with your actual seek implementation when * subclassing! * * @param offset The offset to seek to * @param whence From where to seek.@n * Possible values are: * Value | Description * ---------|--------------------------------------- * SEEK_SET | Seek to the specified byte * SEEK_CUR | Seek to the current location + offset * SEEK_END | Seek to the end of the stream + offset * @return The new offset from the start of the file */ - (off_t)lowlevelSeekToOffset: (off_t)offset whence: (int)whence; @end |
Modified src/OFSeekableStream.m from [7b96bce1bd] to [7c51ea7ed3].
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <stdlib.h> #import "OFSeekableStream.h" @implementation OFSeekableStream | > | | | | > > > | | | > > | 13 14 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 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <stdlib.h> #include <stdio.h> #import "OFSeekableStream.h" @implementation OFSeekableStream - (off_t)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { [self doesNotRecognizeSelector: _cmd]; abort(); } - (off_t)seekToOffset: (off_t)offset whence: (int)whence { if (whence == SEEK_CUR) offset -= _readBufferLength; offset = [self lowlevelSeekToOffset: offset whence: whence]; [self freeMemory: _readBuffer]; _readBuffer = NULL; _readBufferLength = 0; return offset; } @end |