ObjFW  Diff

Differences From Artifact [dfa9456896]:

To Artifact [941019ae14]:


566
567
568
569
570
571
572

573
574
575
576
577
578
579
580
581
582
583
584
585
586

587
588
589
590
591
592
593
594
595


596
597
598
599
600
601
602
603


604
605
606
607
608
609
610
611
612
613


614
615
616
617
618
619
620
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596

597
598
599
600
601
602
603
604
605

606
607
608
609
610
611
612
613
614
615
616

617
618
619
620
621
622
623
624
625







+














+








-
+
+







-
+
+









-
+
+







- (size_t)_readNBytes: (size_t)size
	   intoBuffer: (char*)buf
{
	size_t ret;

	if (fd == -1 || eos)
		@throw [OFReadFailedException newWithClass: isa
						    stream: self
					     requestedSize: size];
	if ((ret = read(fd, buf, size)) == 0)
		eos = YES;

	return ret;
}

- (size_t)_writeNBytes: (size_t)size
	    fromBuffer: (const char*)buf
{
	size_t ret;

	if (fd == -1 || eos || (ret = write(fd, buf, size)) < size)
		@throw [OFWriteFailedException newWithClass: isa
						     stream: self
					      requestedSize: size];

	return ret;
}

- (void)_seekToOffset: (off_t)offset
{
	if (lseek(fd, offset, SEEK_SET) == -1)
		@throw [OFSeekFailedException newWithClass: isa];
		@throw [OFSeekFailedException newWithClass: isa
						    stream: self];
}

- (off_t)_seekForwardWithOffset: (off_t)offset
{
	off_t ret;

	if ((ret = lseek(fd, offset, SEEK_CUR)) == -1)
		@throw [OFSeekFailedException newWithClass: isa];
		@throw [OFSeekFailedException newWithClass: isa
						    stream: self];

	return ret;
}

- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
	off_t ret;

	if ((ret = lseek(fd, offset, SEEK_END)) == -1)
		@throw [OFSeekFailedException newWithClass: isa];
		@throw [OFSeekFailedException newWithClass: isa
						    stream: self];

	return ret;
}

- (int)fileDescriptor
{
	return fd;