ObjFW  Diff

Differences From Artifact [f9aa8dca83]:

To Artifact [9d8368a480]:


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURL.h"
#import "OFURLHandler.h"
#import "OFXMLElement.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"







|
|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFXMLElement.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifdef OF_HAVE_FILES
+ (instancetype)dataWithContentsOfFile: (OFString *)path
{
	return [[[self alloc] initWithContentsOfFile: path] autorelease];
}
#endif

+ (instancetype)dataWithContentsOfURL: (OFURL *)URL
{
	return [[[self alloc] initWithContentsOfURL: URL] autorelease];
}

+ (instancetype)dataWithStringRepresentation: (OFString *)string
{
	return [[[self alloc]
	    initWithStringRepresentation: string] autorelease];
}







|

|







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifdef OF_HAVE_FILES
+ (instancetype)dataWithContentsOfFile: (OFString *)path
{
	return [[[self alloc] initWithContentsOfFile: path] autorelease];
}
#endif

+ (instancetype)dataWithContentsOfURI: (OFURI *)URI
{
	return [[[self alloc] initWithContentsOfURI: URI] autorelease];
}

+ (instancetype)dataWithStringRepresentation: (OFString *)string
{
	return [[[self alloc]
	    initWithStringRepresentation: string] autorelease];
}
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
		@throw e;
	}

	return self;
}
#endif

- (instancetype)initWithContentsOfURL: (OFURL *)URL
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFStream *stream = [OFURLHandler openItemAtURL: URL mode: @"r"];
		size_t pageSize;
		unsigned char *buffer;

		_count = 0;
		_itemSize = 1;
		_freeWhenDone = true;








|





|







211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
		@throw e;
	}

	return self;
}
#endif

- (instancetype)initWithContentsOfURI: (OFURI *)URI
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFStream *stream = [OFURIHandler openItemAtURI: URI mode: @"r"];
		size_t pageSize;
		unsigned char *buffer;

		_count = 0;
		_itemSize = 1;
		_freeWhenDone = true;

587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
		[file writeBuffer: _items length: _count * _itemSize];
	} @finally {
		[file release];
	}
}
#endif

- (void)writeToURL: (OFURL *)URL
{
	void *pool = objc_autoreleasePoolPush();

	[[OFURLHandler openItemAtURL: URL mode: @"w"] writeData: self];

	objc_autoreleasePoolPop(pool);
}

- (OFXMLElement *)XMLElementBySerializing
{
	void *pool;







|



|







587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
		[file writeBuffer: _items length: _count * _itemSize];
	} @finally {
		[file release];
	}
}
#endif

- (void)writeToURI: (OFURI *)URI
{
	void *pool = objc_autoreleasePoolPush();

	[[OFURIHandler openItemAtURI: URI mode: @"w"] writeData: self];

	objc_autoreleasePoolPop(pool);
}

- (OFXMLElement *)XMLElementBySerializing
{
	void *pool;