Differences From Artifact [f9e4a0a447]:
- File
src/OFFile.m
— part of check-in
[440e95fd4a]
at
2012-09-12 17:27:53
on branch trunk
— Split -[OFStream fileDescriptor].
It is now -[fileDescriptorForReading] and -[fileDescriptorForWriting].
The split was necessary as some stream types (e.g. OFProcess) don't have
a single file descriptor, but two. This allows to use those stream types
with OFStreamObserver as well. (user: js, size: 18903) [annotate] [blame] [check-ins using]
To Artifact [a11a54fb53]:
- File src/OFFile.m — part of check-in [61c1932caf] at 2012-09-16 15:43:45 on branch trunk — OFStream: Use lowlevel as prefix instead of _. (user: js, size: 18966) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
681 682 683 684 685 686 687 | self = [super init]; fd = fileDescriptor; return self; } | | | | | | | | | | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | self = [super init]; fd = fileDescriptor; return self; } - (BOOL)lowlevelIsAtEndOfStream { if (fd == -1) return YES; return atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void*)buffer length: (size_t)length { ssize_t ret; if (fd == -1 || atEndOfStream || (ret = read(fd, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithClass: [self class] stream: self requestedLength: length]; if (ret == 0) atEndOfStream = YES; return ret; } - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { if (fd == -1 || atEndOfStream || write(fd, buffer, length) < length) @throw [OFWriteFailedException exceptionWithClass: [self class] stream: self requestedLength: length]; } - (void)lowlevelSeekToOffset: (off_t)offset { if (lseek(fd, offset, SEEK_SET) == -1) @throw [OFSeekFailedException exceptionWithClass: [self class] stream: self offset: offset whence: SEEK_SET]; } - (off_t)lowlevelSeekForwardWithOffset: (off_t)offset { off_t ret; if ((ret = lseek(fd, offset, SEEK_CUR)) == -1) @throw [OFSeekFailedException exceptionWithClass: [self class] stream: self offset: offset whence: SEEK_CUR]; return ret; } - (off_t)lowlevelSeekToOffsetRelativeToEnd: (off_t)offset { off_t ret; if ((ret = lseek(fd, offset, SEEK_END)) == -1) @throw [OFSeekFailedException exceptionWithClass: [self class] stream: self offset: offset |
︙ | ︙ | |||
819 820 821 822 823 824 825 | - (void)dealloc { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of stupid warning */ } | | | | | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | - (void)dealloc { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of stupid warning */ } - (void)lowlevelSeekToOffset: (off_t)offset { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (off_t)lowlevelSeekForwardWithOffset: (off_t)offset { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (off_t)lowlevelSeekToOffsetRelativeToEnd: (off_t)offset { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } @end |