ObjFW  Diff

Differences From Artifact [952e87c05c]:

To Artifact [a5dd4c3dce]:


38
39
40
41
42
43
44

45
46
47
48
49
50
51
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52







+







#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFSeekFailedException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedVersionException.h"
#import "OFWriteFailedException.h"

/*
 * FIXME: Current limitations:
 *  - Split archives are not supported.
 *  - Encrypted files cannot be read.
 */

872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888

889



890
891
892


893

894









895
896
897
898
899
900
901
873
874
875
876
877
878
879


880
881
882
883
884
885
886
887
888

889
890
891
892


893
894
895
896

897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912







-
-








+
-
+
+
+

-
-
+
+

+
-
+
+
+
+
+
+
+
+
+







	[_entry release];

	[super dealloc];
}

- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
{
	size_t bytesWritten;

#if SIZE_MAX >= INT64_MAX
	if (length > INT64_MAX)
		@throw [OFOutOfRangeException exception];
#endif

	if (INT64_MAX - _bytesWritten < (int64_t)length)
		@throw [OFOutOfRangeException exception];

	@try {
	bytesWritten = [_stream writeBuffer: buffer length: length];
		[_stream writeBuffer: buffer length: length];
	} @catch (OFWriteFailedException *e) {
		OFEnsure(e.bytesWritten < length);

	_bytesWritten += (int64_t)bytesWritten;
	_CRC32 = OFCRC32(_CRC32, buffer, length);
		_bytesWritten += (int64_t)e.bytesWritten;
		_CRC32 = OFCRC32(_CRC32, buffer, e.bytesWritten);

		if (e.errNo == EWOULDBLOCK)
	return bytesWritten;
			return e.bytesWritten;

		@throw e;
	}

	_bytesWritten += (int64_t)length;
	_CRC32 = OFCRC32(_CRC32, buffer, length);

	return length;
}

- (void)close
{
	if (_stream == nil)
		@throw [OFNotOpenException exceptionWithObject: self];