Overview
Comment: | Simplify seeking. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
dc1093e2a52a6446c822aa4fde1042ed |
User & Date: | js on 2012-10-29 13:03:53 |
Other Links: | manifest | tags |
Context
2012-10-29
| ||
13:35 | Documentation improvements (add references). check-in: e685b742d9 user: js tags: trunk | |
13:03 | Simplify seeking. check-in: dc1093e2a5 user: js tags: trunk | |
12:35 | Documentation fixes. check-in: 318d5d7e53 user: js tags: trunk | |
Changes
Modified src/OFFile.m from [ffd2b8da5e] to [d382f915ee].
︙ | ︙ | |||
713 714 715 716 717 718 719 720 | if (fd == -1 || atEndOfStream || write(fd, buffer, length) < length) @throw [OFWriteFailedException exceptionWithClass: [self class] stream: self requestedLength: length]; } - (void)lowlevelSeekToOffset: (off_t)offset { | > | | < < < < < < < < < < < < < < < < < < < < < < < < < < | 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | if (fd == -1 || atEndOfStream || write(fd, buffer, length) < length) @throw [OFWriteFailedException exceptionWithClass: [self class] stream: self requestedLength: length]; } - (void)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { if (lseek(fd, offset, whence) == -1) @throw [OFSeekFailedException exceptionWithClass: [self class] stream: self offset: offset whence: whence]; } - (int)fileDescriptorForReading { return fd; } |
︙ | ︙ | |||
818 819 820 821 822 823 824 | { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of stupid warning */ } - (void)lowlevelSeekToOffset: (off_t)offset | < < < < | < < < < < < < | 793 794 795 796 797 798 799 800 801 802 803 804 805 | { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of stupid warning */ } - (void)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } @end |
Modified src/OFSeekableStream.h from [d4678f54b9] to [f4e43f22ad].
︙ | ︙ | |||
24 25 26 27 28 29 30 | #include <sys/types.h> #import "OFStream.h" /*! * @brief A stream that supports seeking. * | | < | | | | < < < | < | < | < > | | < < < < < < < < < | < | < < < < < < < < < | < < < < < < < < | | > | 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 | #include <sys/types.h> #import "OFStream.h" /*! * @brief A stream that supports seeking. * * @note If you want to subclass this, override * @ref lowlevelSeekToOffset:whence:. OFSeekableStream uses this method * and makes it work together with the caching of OFStream. If you * override this methods without the lowlevel prefix, you <i>will</i> * break caching, get broken results and seek to the wrong position! */ @interface OFSeekableStream: OFStream /*! * @brief Seeks to the specified absolute offset. * * @param offset The offset in bytes * @param whence From where to seek. Possible values are: * * 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. */ - (void)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. Possible values are: * * 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. */ - (void)lowlevelSeekToOffset: (off_t)offset whence: (int)whence; @end |
Modified src/OFSeekableStream.m from [3a3c16de1f] to [ff18537f89].
︙ | ︙ | |||
16 17 18 19 20 21 22 | #import "OFSeekableStream.h" #import "OFNotImplementedException.h" @implementation OFSeekableStream - (void)lowlevelSeekToOffset: (off_t)offset | < < < < | < < < < < < < > | | < < < | < < < < < < < < < < < < < < < < < < < < < < | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "OFSeekableStream.h" #import "OFNotImplementedException.h" @implementation OFSeekableStream - (void)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (void)seekToOffset: (off_t)offset whence: (int)whence { [self lowlevelSeekToOffset: offset whence: whence]; [self freeMemory: cache]; cache = NULL; cacheLength = 0; } @end |