ObjFW  Check-in [338d452f33]

Overview
Comment:OFURLHandler: Add +[openItemAtURL:mode:]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 338d452f33e7a2d674095b31df3430ea84771683ef311888ef1625b3f6b57c4f
User & Date: js on 2022-08-11 20:54:05
Other Links: manifest | tags
Context
2022-08-11
23:20
OFURLHandler: Minor documentation fix check-in: 0a3a76c56c user: js tags: trunk
20:54
OFURLHandler: Add +[openItemAtURL:mode:] check-in: 338d452f33 user: js tags: trunk
20:46
OFURLHandler: Make +[handlerForURL:] nonnull check-in: 9e7f4f34b9 user: js tags: trunk
Changes

Modified src/OFData.m from [b6152aa57a] to [d1f758e1e7].

217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

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

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFURLHandler *URLHandler;
		OFStream *stream;
		size_t pageSize;
		unsigned char *buffer;

		if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
			@throw [OFUnsupportedProtocolException
			    exceptionWithURL: URL];

		stream = [URLHandler openItemAtURL: URL mode: @"r"];

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

		pageSize = [OFSystemInfo pageSize];
		buffer = OFAllocMemory(1, pageSize);








<
|



<
<
<
<
<
<







217
218
219
220
221
222
223

224
225
226
227






228
229
230
231
232
233
234

- (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;

		pageSize = [OFSystemInfo pageSize];
		buffer = OFAllocMemory(1, pageSize);

597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
	}
}
#endif

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

	if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

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

	objc_autoreleasePoolPop(pool);
}

- (OFXMLElement *)XMLElementBySerializing
{
	void *pool;







<

<
<
<
|







590
591
592
593
594
595
596

597



598
599
600
601
602
603
604
605
	}
}
#endif

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





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

	objc_autoreleasePoolPop(pool);
}

- (OFXMLElement *)XMLElementBySerializing
{
	void *pool;

Modified src/OFFileManager.m from [8b48822fc3] to [dd95d5c2a1].

656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
		size_t pageSize = [OFSystemInfo pageSize];
		OFStream *sourceStream = nil;
		OFStream *destinationStream = nil;
		char *buffer;

		buffer = OFAllocMemory(1, pageSize);
		@try {
			sourceStream = [[OFURLHandler handlerForURL: source]
			    openItemAtURL: source
				     mode: @"r"];
			destinationStream = [[OFURLHandler handlerForURL:
			    destination] openItemAtURL: destination
						  mode: @"w"];

			while (!sourceStream.atEndOfStream) {
				size_t length;

				length = [sourceStream
				    readIntoBuffer: buffer
					    length: pageSize];







<
|
|
|
|
|







656
657
658
659
660
661
662

663
664
665
666
667
668
669
670
671
672
673
674
		size_t pageSize = [OFSystemInfo pageSize];
		OFStream *sourceStream = nil;
		OFStream *destinationStream = nil;
		char *buffer;

		buffer = OFAllocMemory(1, pageSize);
		@try {

			sourceStream = [OFURLHandler openItemAtURL: source
							      mode: @"r"];
			destinationStream = [OFURLHandler
			    openItemAtURL: destination
				     mode: @"w"];

			while (!sourceStream.atEndOfStream) {
				size_t length;

				length = [sourceStream
				    readIntoBuffer: buffer
					    length: pageSize];

Modified src/OFHTTPURLHandler.m from [c4a43aad17] to [26da6a20ea].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#import "OFHTTPURLHandler.h"
#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"

@implementation OFHTTPURLHandler
- (OFStream *)openItemAtURL: (OFURL *)URL
		       mode: (OFString *)mode
{
	void *pool = objc_autoreleasePoolPush();
	OFHTTPClient *client = [OFHTTPClient client];
	OFHTTPRequest *request = [OFHTTPRequest requestWithURL: URL];
	OFHTTPResponse *response = [client performRequest: request];

	[response retain];

	objc_autoreleasePoolPop(pool);

	return [response autorelease];
}
@end







|
<













17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
32
33
34
35
36
37

#import "OFHTTPURLHandler.h"
#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"

@implementation OFHTTPURLHandler
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode

{
	void *pool = objc_autoreleasePoolPush();
	OFHTTPClient *client = [OFHTTPClient client];
	OFHTTPRequest *request = [OFHTTPRequest requestWithURL: URL];
	OFHTTPResponse *response = [client performRequest: request];

	[response retain];

	objc_autoreleasePoolPop(pool);

	return [response autorelease];
}
@end

Modified src/OFINIFile.m from [5568ad8169] to [6dd903e8a2].

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{
	void *pool = objc_autoreleasePoolPush();
	OFStream *file;
	OFINICategory *category = nil;
	OFString *line;

	@try {
		file = [[OFURLHandler handlerForURL: URL] openItemAtURL: URL
								   mode: @"r"];
	} @catch (OFOpenItemFailedException *e) {
		/* Handle missing file like an empty file */
		if (e.errNo == ENOENT)
			return;

		@throw e;
	}







<
|







114
115
116
117
118
119
120

121
122
123
124
125
126
127
128
{
	void *pool = objc_autoreleasePoolPush();
	OFStream *file;
	OFINICategory *category = nil;
	OFString *line;

	@try {

		file = [OFURLHandler openItemAtURL: URL mode: @"r"];
	} @catch (OFOpenItemFailedException *e) {
		/* Handle missing file like an empty file */
		if (e.errNo == ENOENT)
			return;

		@throw e;
	}
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{
	[self writeToURL: URL encoding: OFStringEncodingUTF8];
}

- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
{
	void *pool = objc_autoreleasePoolPush();
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL
		     mode: @"w"];
	bool first = true;

	for (OFINICategory *category in _categories)
		if ([category of_writeToStream: file
				      encoding: encoding
					 first: first])
			first = false;







<
|
<







157
158
159
160
161
162
163

164

165
166
167
168
169
170
171
{
	[self writeToURL: URL encoding: OFStringEncodingUTF8];
}

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

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"w"];

	bool first = true;

	for (OFINICategory *category in _categories)
		if ([category of_writeToStream: file
				      encoding: encoding
					 first: first])
			first = false;

Modified src/OFString.m from [0292b59c78] to [d6ba8bab44].

2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
{
	[self writeToURL: URL encoding: OFStringEncodingUTF8];
}

- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
{
	void *pool = objc_autoreleasePoolPush();
	OFURLHandler *URLHandler;
	OFStream *stream;

	if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

	stream = [URLHandler openItemAtURL: URL mode: @"w"];
	[stream writeString: self encoding: encoding];

	objc_autoreleasePoolPop(pool);
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block







<


<
<
<
|







2754
2755
2756
2757
2758
2759
2760

2761
2762



2763
2764
2765
2766
2767
2768
2769
2770
{
	[self writeToURL: URL encoding: OFStringEncodingUTF8];
}

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

	OFStream *stream;




	stream = [OFURLHandler openItemAtURL: URL mode: @"w"];
	[stream writeString: self encoding: encoding];

	objc_autoreleasePoolPop(pool);
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block

Modified src/OFURLHandler.h from [3680d34e27] to [ab15a19579].

54
55
56
57
58
59
60
61























62
63
64
65
66
67
68
+ (bool)registerClass: (Class)class_ forScheme: (OFString *)scheme;

/**
 * @brief Returns the handler for the specified URL.
 *
 * @return The handler for the specified URL.
 */
+ (OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL;
























- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Initializes the handler for the specified scheme.
 *
 * @param scheme The scheme to initialize for







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
+ (bool)registerClass: (Class)class_ forScheme: (OFString *)scheme;

/**
 * @brief Returns the handler for the specified URL.
 *
 * @return The handler for the specified URL.
 */
+ (OFURLHandler *)handlerForURL: (OFURL *)URL;

/**
 * @brief Opens the item at the specified URL.
 *
 * @param URL The URL of the item which should be opened
 * @param mode The mode in which the file should be opened.@n
 *	       Possible modes are:
 *	       @n
 *	       Mode           | Description
 *	       ---------------|-------------------------------------
 *	       `r`            | Read-only
 *	       `r+`           | Read-write
 *	       `w`            | Write-only, create or truncate
 *	       `wx`           | Write-only, create or fail, exclusive
 *	       `w+`           | Read-write, create or truncate
 *	       `w+x`          | Read-write, create or fail, exclusive
 *	       `a`            | Write-only, create or append
 *	       `a+`           | Read-write, create or append
 *	       @n
 *	       The handler is allowed to not implement all modes and is also
 *	       allowed to implement additional, scheme-specific modes.
 */
+ (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode;

- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Initializes the handler for the specified scheme.
 *
 * @param scheme The scheme to initialize for

Modified src/OFURLHandler.m from [fd7a23df40] to [b307a96ca2].

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118





119
120
121
122
123
124
125
		[mutex unlock];
	}
#endif

	return true;
}

+ (OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL
{
	OF_KINDOF(OFURLHandler *) handler;

#ifdef OF_HAVE_THREADS
	[mutex lock];
	@try {
#endif
		handler = [handlers objectForKey: URL.scheme];
#ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
#endif

	if (handler == nil)
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

	return handler;
}






- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithScheme: (OFString *)scheme







|



















>
>
>
>
>







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
		[mutex unlock];
	}
#endif

	return true;
}

+ (OFURLHandler *)handlerForURL: (OFURL *)URL
{
	OF_KINDOF(OFURLHandler *) handler;

#ifdef OF_HAVE_THREADS
	[mutex lock];
	@try {
#endif
		handler = [handlers objectForKey: URL.scheme];
#ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
#endif

	if (handler == nil)
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

	return handler;
}

+ (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
{
	return [[self handlerForURL: URL] openItemAtURL: URL mode: mode];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithScheme: (OFString *)scheme

Modified tests/OFHMACTests.m from [bac63969c0] to [38283dce16].

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    "\xB7\xE8\x87\xC1\x73\x19\x63\xF6\xA2\x91\x8D\x7E\x2E\xCC\xEC\x99";

@implementation TestsAppDelegate (OFHMACTests)
- (void)HMACTests
{
	void *pool = objc_autoreleasePoolPush();
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];
	OFHMAC *HMACMD5, *HMACSHA1, *HMACRMD160;
	OFHMAC *HMACSHA256, *HMACSHA384, *HMACSHA512;

	TEST(@"+[HMACWithHashClass:] with MD5",
	    (HMACMD5 = [OFHMAC HMACWithHashClass: [OFMD5Hash class]
			   allowsSwappableMemory: true]))
	TEST(@"+[HMACWithHashClass:] with SHA-1",







<
|







48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
    "\xB7\xE8\x87\xC1\x73\x19\x63\xF6\xA2\x91\x8D\x7E\x2E\xCC\xEC\x99";

@implementation TestsAppDelegate (OFHMACTests)
- (void)HMACTests
{
	void *pool = objc_autoreleasePoolPush();
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];
	OFHMAC *HMACMD5, *HMACSHA1, *HMACRMD160;
	OFHMAC *HMACSHA256, *HMACSHA384, *HMACSHA512;

	TEST(@"+[HMACWithHashClass:] with MD5",
	    (HMACMD5 = [OFHMAC HMACWithHashClass: [OFMD5Hash class]
			   allowsSwappableMemory: true]))
	TEST(@"+[HMACWithHashClass:] with SHA-1",

Modified tests/OFMD5HashTests.m from [66b4d11501] to [97c4cf5d1a].

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

@implementation TestsAppDelegate (OFMD5HashTests)
- (void)MD5HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFMD5Hash *MD5, *MD5Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (MD5 = [OFMD5Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];







<
|







26
27
28
29
30
31
32

33
34
35
36
37
38
39
40

@implementation TestsAppDelegate (OFMD5HashTests)
- (void)MD5HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFMD5Hash *MD5, *MD5Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (MD5 = [OFMD5Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFRIPEMD160HashTests.m from [d9eb71eb42] to [3419cbc976].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

@implementation TestsAppDelegate (OFRIPEMD160HashTests)
- (void)RIPEMD160HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFRIPEMD160Hash *RIPEMD160, *RIPEMD160Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (RIPEMD160 = [OFRIPEMD160Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];







<
|







27
28
29
30
31
32
33

34
35
36
37
38
39
40
41

@implementation TestsAppDelegate (OFRIPEMD160HashTests)
- (void)RIPEMD160HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFRIPEMD160Hash *RIPEMD160, *RIPEMD160Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (RIPEMD160 = [OFRIPEMD160Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA1HashTests.m from [8dbe2b957f] to [f253b9db0c].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

@implementation TestsAppDelegate (SHA1HashTests)
- (void)SHA1HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA1Hash *SHA1, *SHA1Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA1 = [OFSHA1Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];







<
|







27
28
29
30
31
32
33

34
35
36
37
38
39
40
41

@implementation TestsAppDelegate (SHA1HashTests)
- (void)SHA1HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA1Hash *SHA1, *SHA1Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA1 = [OFSHA1Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA224HashTests.m from [3be83604b4] to [9b914752b4].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

@implementation TestsAppDelegate (SHA224HashTests)
- (void)SHA224HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA224Hash *SHA224, *SHA224Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA224 = [OFSHA224Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];







<
|







27
28
29
30
31
32
33

34
35
36
37
38
39
40
41

@implementation TestsAppDelegate (SHA224HashTests)
- (void)SHA224HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA224Hash *SHA224, *SHA224Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA224 = [OFSHA224Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA256HashTests.m from [2658ed96c0] to [7f8af4714a].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

@implementation TestsAppDelegate (SHA256HashTests)
- (void)SHA256HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA256Hash *SHA256, *SHA256Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA256 = [OFSHA256Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];







<
|







27
28
29
30
31
32
33

34
35
36
37
38
39
40
41

@implementation TestsAppDelegate (SHA256HashTests)
- (void)SHA256HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA256Hash *SHA256, *SHA256Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA256 = [OFSHA256Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA384HashTests.m from [dd9d5ffdb4] to [22ee9524a1].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

@implementation TestsAppDelegate (SHA384HashTests)
- (void)SHA384HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA384Hash *SHA384, *SHA384Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA384 = [OFSHA384Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[128];
		size_t length = [file readIntoBuffer: buffer length: 128];







<
|







28
29
30
31
32
33
34

35
36
37
38
39
40
41
42

@implementation TestsAppDelegate (SHA384HashTests)
- (void)SHA384HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA384Hash *SHA384, *SHA384Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA384 = [OFSHA384Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[128];
		size_t length = [file readIntoBuffer: buffer length: 128];

Modified tests/OFSHA512HashTests.m from [759fed7ea6] to [7aae15f950].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

@implementation TestsAppDelegate (SHA512HashTests)
- (void)SHA512HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA512Hash *SHA512, *SHA512Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA512 = [OFSHA512Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[128];
		size_t length = [file readIntoBuffer: buffer length: 128];







<
|







29
30
31
32
33
34
35

36
37
38
39
40
41
42
43

@implementation TestsAppDelegate (SHA512HashTests)
- (void)SHA512HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA512Hash *SHA512, *SHA512Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];

	OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA512 = [OFSHA512Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[128];
		size_t length = [file readIntoBuffer: buffer length: 128];