ObjFW  Diff

Differences From Artifact [a97d47a4cf]:

To Artifact [02ef45c9df]:


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFStatItemFailedException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedProtocolException.h"

#import "of_asprintf.h"
#import "unicode.h"

/*







|







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFRetrieveItemAttributesFailedException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedProtocolException.h"

#import "of_asprintf.h"
#import "unicode.h"

/*
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020

1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032

1033

1034
1035

1036
1037
1038
1039
1040
1041
1042
				   encoding: OF_STRING_ENCODING_UTF_8];
}

- (instancetype)initWithContentsOfFile: (OFString *)path
			      encoding: (of_string_encoding_t)encoding
{
	char *tmp;
	of_offset_t fileSize;

	@try {

		OFFile *file;

		@try {
			fileSize = [[OFFileManager defaultManager]
			    sizeOfFileAtPath: path];
		} @catch (OFStatItemFailedException *e) {
			@throw [OFOpenItemFailedException
			    exceptionWithPath: path
					 mode: @"r"
					errNo: errno];
		}


		if (sizeof(of_offset_t) > sizeof(size_t) &&

		    fileSize > (of_offset_t)SIZE_MAX)
			@throw [OFOutOfRangeException exception];


		file = [[OFFile alloc] initWithPath: path
					       mode: @"r"];

		@try {
			tmp = [self allocMemoryWithSize: (size_t)fileSize];








|


>



|
|
|






>
|
>
|

>







1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
				   encoding: OF_STRING_ENCODING_UTF_8];
}

- (instancetype)initWithContentsOfFile: (OFString *)path
			      encoding: (of_string_encoding_t)encoding
{
	char *tmp;
	uintmax_t fileSize;

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFFile *file;

		@try {
			fileSize = [[[OFFileManager defaultManager]
			    attributesOfItemAtPath: path] fileSize];
		} @catch (OFRetrieveItemAttributesFailedException *e) {
			@throw [OFOpenItemFailedException
			    exceptionWithPath: path
					 mode: @"r"
					errNo: errno];
		}

		objc_autoreleasePoolPop(pool);

# if UINTMAX_MAX > SIZE_MAX
		if (fileSize > SIZE_MAX)
			@throw [OFOutOfRangeException exception];
#endif

		file = [[OFFile alloc] initWithPath: path
					       mode: @"r"];

		@try {
			tmp = [self allocMemoryWithSize: (size_t)fileSize];