Modified generators/library/LibraryGenerator.m
from [0e687972e3]
to [69ede2939c].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
|
*/
#include "config.h"
#import "OFApplication.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFXMLElement.h"
#import "FuncArrayGenerator.h"
#import "GlueGenerator.h"
#import "LinkLibGenerator.h"
@interface LibraryGenerator: OFObject <OFApplicationDelegate>
@end
OF_APPLICATION_DELEGATE(LibraryGenerator)
@implementation LibraryGenerator
- (void)applicationDidFinishLaunching
{
OFURL *sourcesURL = [[OFFileManager defaultManager].currentDirectoryURL
URLByAppendingPathComponent: @"../../src"];
OFURL *runtimeLibraryURL = [sourcesURL
URLByAppendingPathComponent: @"runtime/amiga-library.xml"];
OFURL *runtimeLinkLibURL = [sourcesURL
URLByAppendingPathComponent: @"runtime/linklib/linklib.m"];
OFURL *runtimeGlueHeaderURL = [sourcesURL
URLByAppendingPathComponent: @"runtime/amiga-glue.h"];
OFURL *runtimeGlueURL = [sourcesURL
URLByAppendingPathComponent: @"runtime/amiga-glue.m"];
OFURL *runtimeFuncArrayURL = [sourcesURL
URLByAppendingPathComponent: @"runtime/amiga-funcarray.inc"];
OFURI *sourcesURI = [[OFFileManager defaultManager].currentDirectoryURI
URIByAppendingPathComponent: @"../../src"];
OFURI *runtimeLibraryURI = [sourcesURI
URIByAppendingPathComponent: @"runtime/amiga-library.xml"];
OFURI *runtimeLinkLibURI = [sourcesURI
URIByAppendingPathComponent: @"runtime/linklib/linklib.m"];
OFURI *runtimeGlueHeaderURI = [sourcesURI
URIByAppendingPathComponent: @"runtime/amiga-glue.h"];
OFURI *runtimeGlueURI = [sourcesURI
URIByAppendingPathComponent: @"runtime/amiga-glue.m"];
OFURI *runtimeFuncArrayURI = [sourcesURI
URIByAppendingPathComponent: @"runtime/amiga-funcarray.inc"];
OFXMLElement *runtimeLibrary = [OFXMLElement elementWithStream:
[OFFile fileWithPath: runtimeLibraryURL.fileSystemRepresentation
[OFFile fileWithPath: runtimeLibraryURI.fileSystemRepresentation
mode: @"r"]];
OFFile *runtimeLinkLib =
[OFFile fileWithPath: runtimeLinkLibURL.fileSystemRepresentation
[OFFile fileWithPath: runtimeLinkLibURI.fileSystemRepresentation
mode: @"w"];
OFFile *runtimeGlueHeader =
[OFFile fileWithPath: runtimeGlueHeaderURL.fileSystemRepresentation
[OFFile fileWithPath: runtimeGlueHeaderURI.fileSystemRepresentation
mode: @"w"];
OFFile *runtimeGlue =
[OFFile fileWithPath: runtimeGlueURL.fileSystemRepresentation
[OFFile fileWithPath: runtimeGlueURI.fileSystemRepresentation
mode: @"w"];
OFFile *runtimeFuncArray =
[OFFile fileWithPath: runtimeFuncArrayURL.fileSystemRepresentation
[OFFile fileWithPath: runtimeFuncArrayURI.fileSystemRepresentation
mode: @"w"];
LinkLibGenerator *runtimeLinkLibGenerator = [[[LinkLibGenerator alloc]
initWithLibrary: runtimeLibrary
implementation: runtimeLinkLib] autorelease];
GlueGenerator *runtimeGlueGenerator = [[[GlueGenerator alloc]
initWithLibrary: runtimeLibrary
header: runtimeGlueHeader
|
︙ | | |
Modified generators/unicode/TableGenerator.m
from [a0b87cdfb8]
to [c1835e042f].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
-
+
-
+
|
#include "config.h"
#include <string.h>
#import "OFString.h"
#import "OFArray.h"
#import "OFApplication.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFHTTPClient.h"
#import "OFFile.h"
#import "OFStdIOStream.h"
#import "OFOutOfRangeException.h"
#import "TableGenerator.h"
#import "copyright.h"
static OFString *const unicodeDataURL =
static OFString *const unicodeDataURI =
@"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt";
static OFString *const caseFoldingURL =
static OFString *const caseFoldingURI =
@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt";
OF_APPLICATION_DELEGATE(TableGenerator)
@implementation TableGenerator
- (instancetype)init
{
|
︙ | | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
-
-
+
+
|
- (void)applicationDidFinishLaunching
{
OFHTTPRequest *request;
[OFStdOut writeString: @"Downloading UnicodeData.txt…"];
_state = stateUnicodeData;
request = [OFHTTPRequest requestWithURL:
[OFURL URLWithString: unicodeDataURL]];
request = [OFHTTPRequest requestWithURI:
[OFURI URIWithString: unicodeDataURI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
exception: (id)exception
|
︙ | | |
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
-
+
+
|
[self applyDecompositionRecursivelyForTable: _decompositionTable];
[self applyDecompositionRecursivelyForTable: _decompositionCompatTable];
[OFStdOut writeLine: @" done"];
[OFStdOut writeString: @"Downloading CaseFolding.txt…"];
_state = stateCaseFolding;
request = [OFHTTPRequest requestWithURL:
[OFURL URLWithString: caseFoldingURL]];
request = [OFHTTPRequest requestWithURI:
[OFURI URIWithString: caseFoldingURI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)parseCaseFolding: (OFHTTPResponse *)response
{
OFString *line;
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
-
+
-
-
+
+
-
-
+
+
|
objc_autoreleasePoolPop(pool);
}
} while (!done);
}
- (void)writeFiles
{
OFURL *URL;
OFURI *URI;
[OFStdOut writeString: @"Writing files…"];
URL = [OFURL fileURLWithPath: @"../../src/unicode.m"];
[self writeTablesToFile: URL.fileSystemRepresentation];
URI = [OFURI fileURIWithPath: @"../../src/unicode.m"];
[self writeTablesToFile: URI.fileSystemRepresentation];
URL = [OFURL fileURLWithPath: @"../../src/unicode.h"];
[self writeHeaderToFile: URL.fileSystemRepresentation];
URI = [OFURI fileURIWithPath: @"../../src/unicode.h"];
[self writeHeaderToFile: URI.fileSystemRepresentation];
[OFStdOut writeLine: @" done"];
[OFApplication terminate];
}
- (void)writeTablesToFile: (OFString *)path
|
︙ | | |
Modified src/Makefile
from [cb5cb1168b]
to [d4fba39890].
︙ | | |
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
-
+
|
OFMutableDictionary.m \
OFMutableLHAArchiveEntry.m \
OFMutablePair.m \
OFMutableSet.m \
OFMutableString.m \
OFMutableTarArchiveEntry.m \
OFMutableTriple.m \
OFMutableURL.m \
OFMutableURI.m \
OFMutableZIPArchiveEntry.m \
OFNotification.m \
OFNotificationCenter.m \
OFNull.m \
OFNumber.m \
OFObject.m \
OFObject+KeyValueCoding.m \
|
︙ | | |
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
+
-
-
-
+
+
|
OFSet.m \
OFSortedList.m \
OFStdIOStream.m \
OFStream.m \
OFString.m \
OFString+CryptographicHashing.m \
OFString+JSONParsing.m \
OFString+PercentEncoding.m \
OFString+PropertyListParsing.m \
OFString+Serialization.m \
OFString+URLEncoding.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
${OF_SUBPROCESS_M} \
OFSettings.m \
OFSystemInfo.m \
OFTarArchive.m \
OFTarArchiveEntry.m \
OFThread.m \
OFTimer.m \
OFTriple.m \
OFURL.m \
OFURLHandler.m \
OFURI.m \
OFURIHandler.m \
OFUUID.m \
OFValue.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
OFXMLElement.m \
|
︙ | | |
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-
+
|
OFAdjacentSubarray.m \
OFBase64.m \
OFBitSetCharacterSet.m \
OFBytesValue.m \
OFCRC16.m \
OFCRC32.m \
OFCountedMapTableSet.m \
OFEmbeddedFileURLHandler.m \
OFEmbeddedURIHandler.m \
OFHuffmanTree.m \
OFINIFileSettings.m \
OFInvertedCharacterSet.m \
OFLHADecompressingStream.m \
OFMapTableDictionary.m \
OFMapTableSet.m \
OFMutableAdjacentArray.m \
|
︙ | | |
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
-
+
-
+
|
OFStrPTime.m \
OFSubarray.m \
OFUTF8String.m \
${LIBBASES_M} \
${RUNTIME_AUTORELEASE_M} \
${RUNTIME_INSTANCE_M} \
${UNICODE_M}
SRCS_FILES += OFFileURLHandler.m
SRCS_FILES += OFFileURIHandler.m
SRCS_SOCKETS += OFDNSResolverSettings.m \
${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \
OFHTTPURLHandler.m \
OFHTTPURIHandler.m \
OFHostAddressResolver.m \
OFIPSocketAsyncConnector.m \
OFKernelEventObserver.m \
${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \
${OF_POLL_KERNEL_EVENT_OBSERVER_M} \
${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \
OFTCPSocketSOCKS5Connector.m
|
︙ | | |
Modified src/OFConstantString.m
from [d0c2668f14]
to [3adc07df05].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
- (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
[self writeToFile: path encoding: encoding];
}
#endif
- (void)writeToURL: (OFURL *)URL
- (void)writeToURI: (OFURI *)URI
{
[self finishInitialization];
[self writeToURL: URL];
[self writeToURI: URI];
}
- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
[self writeToURL: URL encoding: encoding];
[self writeToURI: URI encoding: encoding];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block
{
[self finishInitialization];
[self enumerateLinesUsingBlock: block];
}
#endif
@end
|
Modified src/OFData.h
from [8cd28fb97f]
to [750f7eff94].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
-
+
|
#import "OFMessagePackRepresentation.h"
/*! @file */
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFURL;
@class OFURI;
/**
* @brief Options for searching in data.
*
* This is a bit mask.
*/
typedef enum {
|
︙ | | |
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
-
+
-
+
-
+
|
* @return A new autoreleased OFData
*/
+ (instancetype)dataWithContentsOfFile: (OFString *)path;
#endif
/**
* @brief Creates a new OFData with an item size of 1, containing the data of
* the specified URL.
* the specified URI.
*
* @param URL The URL to the contents for the OFData
* @param URI The URI to the contents for the OFData
* @return A new autoreleased OFData
*/
+ (instancetype)dataWithContentsOfURL: (OFURL *)URL;
+ (instancetype)dataWithContentsOfURI: (OFURI *)URI;
/**
* @brief Creates a new OFData with an item size of 1, containing the data of
* the hex string representation.
*
* @param string The hex string representation of the data
* @return A new autoreleased OFData
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
-
+
-
+
-
+
|
* @return An initialized OFData
*/
- (instancetype)initWithContentsOfFile: (OFString *)path;
#endif
/**
* @brief Initializes an already allocated OFData with an item size of 1,
* containing the data of the specified URL.
* containing the data of the specified URI.
*
* @param URL The URL to the contents for the OFData
* @param URI The URI to the contents for the OFData
* @return A new autoreleased OFData
*/
- (instancetype)initWithContentsOfURL: (OFURL *)URL;
- (instancetype)initWithContentsOfURI: (OFURI *)URI;
/**
* @brief Initializes an already allocated OFData with an item size of 1,
* containing the data of the hex string representation.
*
* @param string The hex string representation of the data
* @return A new autoreleased OFData
|
︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
-
+
-
+
-
+
|
*
* @param path The path of the file to write to
*/
- (void)writeToFile: (OFString *)path;
#endif
/**
* @brief Writes the OFData to the specified URL.
* @brief Writes the OFData to the specified URI.
*
* @param URL The URL to write to
* @param URI The URI to write to
*/
- (void)writeToURL: (OFURL *)URL;
- (void)writeToURI: (OFURI *)URI;
@end
OF_ASSUME_NONNULL_END
#import "OFMutableData.h"
#import "OFData+CryptographicHashing.h"
#import "OFData+MessagePackParsing.h"
|
Modified src/OFData.m
from [f9aa8dca83]
to [9d8368a480].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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 "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
|
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
+ (instancetype)dataWithContentsOfURI: (OFURI *)URI
{
return [[[self alloc] initWithContentsOfURL: URL] autorelease];
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
|
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
- (instancetype)initWithContentsOfURI: (OFURI *)URI
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFStream *stream = [OFURLHandler openItemAtURL: URL mode: @"r"];
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
|
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)writeToURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
[[OFURLHandler openItemAtURL: URL mode: @"w"] writeData: self];
[[OFURIHandler openItemAtURI: URI mode: @"w"] writeData: self];
objc_autoreleasePoolPop(pool);
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool;
|
︙ | | |
Modified src/OFDictionary.h
from [0606348126]
to [c2fdfea4e8].
︙ | | |
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
-
+
-
+
|
/**
* @brief An array of all objects.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(ObjectType) *allObjects;
/**
* @brief A URL-encoded string with the contents of the dictionary.
* @brief The dictionary as a URI query string.
*/
@property (readonly, nonatomic) OFString *stringByURLEncoding;
@property (readonly, nonatomic) OFString *URIQueryString;
/**
* @brief Creates a new OFDictionary.
*
* @return A new autoreleased OFDictionary
*/
+ (instancetype)dictionary;
|
︙ | | |
Modified src/OFDictionary.m
from [a48510c034]
to [2aa21595b1].
︙ | | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
-
+
|
#import "OFOutOfRangeException.h"
#import "OFUndefinedKeyException.h"
static struct {
Class isa;
} placeholder;
static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryPartAllowedCharacterSet = nil;
@interface OFDictionary ()
- (OFString *)
of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
depth: (size_t)depth;
@end
|
︙ | | |
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
-
-
+
+
|
OFEnumerator *_keyEnumerator;
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary;
@end
OF_DIRECT_MEMBERS
@interface OFURLQueryPartAllowedCharacterSet: OFCharacterSet
+ (OFCharacterSet *)URLQueryPartAllowedCharacterSet;
@interface OFURIQueryPartAllowedCharacterSet: OFCharacterSet
+ (OFCharacterSet *)URIQueryPartAllowedCharacterSet;
@end
@implementation OFDictionaryPlaceholder
- (instancetype)init
{
return (id)[[OFMapTableDictionary alloc] init];
}
|
︙ | | |
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
-
+
-
+
-
-
+
+
-
+
-
+
|
- (void)dealloc
{
OF_DEALLOC_UNSUPPORTED
}
@end
@implementation OFURLQueryPartAllowedCharacterSet
@implementation OFURIQueryPartAllowedCharacterSet
+ (void)initialize
{
if (self != [OFURLQueryPartAllowedCharacterSet class])
if (self != [OFURIQueryPartAllowedCharacterSet class])
return;
URLQueryPartAllowedCharacterSet =
[[OFURLQueryPartAllowedCharacterSet alloc] init];
URIQueryPartAllowedCharacterSet =
[[OFURIQueryPartAllowedCharacterSet alloc] init];
}
+ (OFCharacterSet *)URLQueryPartAllowedCharacterSet
+ (OFCharacterSet *)URIQueryPartAllowedCharacterSet
{
return URLQueryPartAllowedCharacterSet;
return URIQueryPartAllowedCharacterSet;
}
- (instancetype)autorelease
{
return self;
}
|
︙ | | |
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
|
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
|
-
+
-
-
+
+
-
+
+
-
+
+
|
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (OFString *)stringByURLEncoding
- (OFString *)URIQueryString
{
OFMutableString *ret = [OFMutableString string];
void *pool = objc_autoreleasePoolPush();
OFEnumerator *keyEnumerator = [self keyEnumerator];
OFEnumerator *objectEnumerator = [self objectEnumerator];
OFCharacterSet *allowed = [OFURLQueryPartAllowedCharacterSet
URLQueryPartAllowedCharacterSet];
OFCharacterSet *allowed = [OFURIQueryPartAllowedCharacterSet
URIQueryPartAllowedCharacterSet];
bool first = true;
OFObject *key, *object;
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
if OF_UNLIKELY (first)
first = false;
else
[ret appendString: @"&"];
[ret appendString: [key.description
stringByURLEncodingWithAllowedCharacters: allowed]];
stringByAddingPercentEncodingWithAllowedCharacters:
allowed]];
[ret appendString: @"="];
[ret appendString: [object.description
stringByURLEncodingWithAllowedCharacters: allowed]];
stringByAddingPercentEncodingWithAllowedCharacters:
allowed]];
}
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
|
︙ | | |
Renamed and modified
src/OFEmbeddedFileURLHandler.h
[b889d68d61]
to src/OFEmbeddedURIHandler.h
[5163464dd8].
︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
-
+
-
+
|
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURLHandler.h"
#import "OFURIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFEmbeddedFileURLHandler: OFURLHandler
@interface OFEmbeddedURIHandler: OFURIHandler
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFEmbeddedFileURLHandler.m
[10ad5c2607]
to src/OFEmbeddedURIHandler.m
[4e495a4837].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
+
-
+
|
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#import "OFEmbeddedFileURLHandler.h"
#import "OFEmbeddedURIHandler.h"
#import "OFMemoryStream.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
#ifdef OF_HAVE_THREADS
# import "OFOnce.h"
# import "OFPlainMutex.h"
|
︙ | | |
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
92
93
94
95
96
|
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
92
93
94
95
96
|
-
-
+
+
-
-
-
+
+
+
-
+
-
+
|
numEmbeddedFiles++;
#ifdef OF_HAVE_THREADS
OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
#endif
}
@implementation OFEmbeddedFileURLHandler
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
@implementation OFEmbeddedURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
{
const char *path;
if (![URL.scheme isEqual: @"objfw-embedded"] || URL.host != nil ||
URL.port != nil || URL.user != nil || URL.password != nil ||
URL.query != nil || URL.fragment != nil)
if (![URI.scheme isEqual: @"objfw-embedded"] || URI.host != nil ||
URI.port != nil || URI.user != nil || URI.password != nil ||
URI.query != nil || URI.fragment != nil)
@throw [OFInvalidArgumentException exception];
if (![mode isEqual: @"r"])
@throw [OFOpenItemFailedException exceptionWithURL: URL
@throw [OFOpenItemFailedException exceptionWithURI: URI
mode: mode
errNo: EROFS];
if ((path = URL.path.UTF8String) == NULL) {
if ((path = URI.path.UTF8String) == NULL) {
@throw [OFInvalidArgumentException exception];
}
#ifdef OF_HAVE_THREADS
OFEnsure(OFPlainMutexLock(&mutex) == 0);
@try {
#endif
|
︙ | | |
106
107
108
109
110
111
112
113
114
115
116
117
|
106
107
108
109
110
111
112
113
114
115
116
117
|
-
+
|
}
#ifdef OF_HAVE_THREADS
} @finally {
OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
}
#endif
@throw [OFOpenItemFailedException exceptionWithURL: URL
@throw [OFOpenItemFailedException exceptionWithURI: URI
mode: mode
errNo: ENOENT];
}
@end
|
Modified src/OFFile.h
from [8a72487bc6]
to [b56cdf66da].
︙ | | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
-
+
|
#else
typedef struct _OFFileHandle *OFFileHandle;
static const OFFileHandle OFInvalidFileHandle = NULL;
#endif
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFFile OFFile.h ObjFW/OFFile.h
*
* @brief A class which provides methods to read and write files.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
Modified src/OFFile.m
from [233f3b1153]
to [57c941bba1].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
|
# include <sys/stat.h>
#endif
#import "OFFile.h"
#import "OFLocale.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
|
︙ | | |
Modified src/OFFileManager.h
from [3b6a749b5e]
to [e4a86375d1].
︙ | | |
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
+
-
+
-
+
-
+
-
+
|
# endif
#endif
@class OFArray OF_GENERIC(ObjectType);
@class OFConstantString;
@class OFDate;
@class OFString;
@class OFURL;
@class OFURI;
/**
* @brief A key for a file attribute in the file attributes dictionary.
*
* Possible keys for file URLs are:
* Possible keys for file URIs are:
*
* * @ref OFFileSize
* * @ref OFFileType
* * @ref OFFilePOSIXPermissions
* * @ref OFFileOwnerAccountID
* * @ref OFFileGroupOwnerAccountID
* * @ref OFFileOwnerAccountName
* * @ref OFFileGroupOwnerAccountName
* * @ref OFFileLastAccessDate
* * @ref OFFileModificationDate
* * @ref OFFileStatusChangeDate
* * @ref OFFileCreationDate
* * @ref OFFileSymbolicLinkDestination
*
* Other URL schemes might not have all keys and might have keys not listed.
* Other URI schemes might not have all keys and might have keys not listed.
*/
typedef OFConstantString *OFFileAttributeKey;
/**
* @brief The type of a file.
*
* Possibles values for file URLs are:
* Possibles values for file URIs are:
*
* * @ref OFFileTypeRegular
* * @ref OFFileTypeDirectory
* * @ref OFFileTypeSymbolicLink
* * @ref OFFileTypeFIFO
* * @ref OFFileTypeCharacterSpecial
* * @ref OFFileTypeBlockSpecial
* * @ref OFFileTypeSocket
* * @ref OFFileTypeUnknown
*
* Other URL schemes might not have all types and might have types not listed.
* Other URI schemes might not have all types and might have types not listed.
*/
typedef OFConstantString *OFFileAttributeType;
/**
* @brief A dictionary mapping keys of type @ref OFFileAttributeKey to their
* attribute values.
*/
|
︙ | | |
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
-
+
-
+
|
* @brief The path of the current working directory.
*
* @throw OFGetCurrentDirectoryFailedException Couldn't get current directory
*/
@property (readonly, nonatomic) OFString *currentDirectoryPath;
/**
* @brief The URL of the current working directory.
* @brief The URI of the current working directory.
*
* @throw OFGetCurrentDirectoryFailedException Couldn't get current directory
*/
@property (readonly, nonatomic) OFURL *currentDirectoryURL;
@property (readonly, nonatomic) OFURI *currentDirectoryURI;
#endif
/**
* @brief Returns the default file manager.
*/
+ (OFFileManager *)defaultManager;
|
︙ | | |
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
|
* @throw OFGetItemAttributesFailedException Failed to get the attributes of
* the item
*/
- (OFFileAttributes)attributesOfItemAtPath: (OFString *)path;
#endif
/**
* @brief Returns the attributes for the item at the specified URL.
* @brief Returns the attributes for the item at the specified URI.
*
* @param URL The URL to return the attributes for
* @return A dictionary of attributes for the specified URL, with the keys of
* @param URI The URI to return the attributes for
* @return A dictionary of attributes for the specified URI, with the keys of
* type @ref OFFileAttributeKey
* @throw OFGetItemAttributesFailedException Failed to get the attributes of
* the item
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (OFFileAttributes)attributesOfItemAtURL: (OFURL *)URL;
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI;
#ifdef OF_HAVE_FILES
/**
* @brief Sets the attributes for the item at the specified path.
*
* All attributes not part of the dictionary are left unchanged.
*
* @param attributes The attributes to set for the specified path
* @param path The path of the item to set the attributes for
* @throw OFSetItemAttributesFailedException Failed to set the attributes of
* the item
* @throw OFNotImplementedException Setting one or more of the specified
* attributes is not implemented for the
* specified item
*/
- (void)setAttributes: (OFFileAttributes)attributes
ofItemAtPath: (OFString *)path;
#endif
/**
* @brief Sets the attributes for the item at the specified URL.
* @brief Sets the attributes for the item at the specified URI.
*
* All attributes not part of the dictionary are left unchanged.
*
* @param attributes The attributes to set for the specified URL
* @param URL The URL of the item to set the attributes for
* @param attributes The attributes to set for the specified URI
* @param URI The URI of the item to set the attributes for
* @throw OFSetItemAttributesFailedException Failed to set the attributes of
* the item
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
* @throw OFNotImplementedException Setting one or more of the specified
* attributes is not implemented for the
* specified item
*/
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURL: (OFURL *)URL;
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI;
#ifdef OF_HAVE_FILES
/**
* @brief Checks whether a file exists at the specified path.
*
* @param path The path to check
* @return A boolean whether there is a file at the specified path
*/
- (bool)fileExistsAtPath: (OFString *)path;
#endif
/**
* @brief Checks whether a file exists at the specified URL.
* @brief Checks whether a file exists at the specified URI.
*
* @param URL The URL to check
* @return A boolean whether there is a file at the specified URL
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @param URI The URI to check
* @return A boolean whether there is a file at the specified URI
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (bool)fileExistsAtURL: (OFURL *)URL;
- (bool)fileExistsAtURI: (OFURI *)URI;
#ifdef OF_HAVE_FILES
/**
* @brief Checks whether a directory exists at the specified path.
*
* @param path The path to check
* @return A boolean whether there is a directory at the specified path
*/
- (bool)directoryExistsAtPath: (OFString *)path;
#endif
/**
* @brief Checks whether a directory exists at the specified URL.
* @brief Checks whether a directory exists at the specified URI.
*
* @param URL The URL to check
* @return A boolean whether there is a directory at the specified URL
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @param URI The URI to check
* @return A boolean whether there is a directory at the specified URI
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (bool)directoryExistsAtURL: (OFURL *)URL;
- (bool)directoryExistsAtURI: (OFURI *)URI;
#ifdef OF_HAVE_FILES
/**
* @brief Creates a directory at the specified path.
*
* @param path The path of the directory to create
* @throw OFCreateDirectoryFailedException Creating the directory failed
|
︙ | | |
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
|
* parents failed
*/
- (void)createDirectoryAtPath: (OFString *)path
createParents: (bool)createParents;
#endif
/**
* @brief Creates a directory at the specified URL.
* @brief Creates a directory at the specified URI.
*
* @param URL The URL of the directory to create
* @param URI The URI of the directory to create
* @throw OFCreateDirectoryFailedException Creating the directory failed
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (void)createDirectoryAtURL: (OFURL *)URL;
- (void)createDirectoryAtURI: (OFURI *)URI;
/**
* @brief Creates a directory at the specified URL.
* @brief Creates a directory at the specified URI.
*
* @param URL The URL of the directory to create
* @param URI The URI of the directory to create
* @param createParents Whether to create the parents of the directory
* @throw OFCreateDirectoryFailedException Creating the directory or one of its
* parents failed
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (void)createDirectoryAtURL: (OFURL *)URL createParents: (bool)createParents;
- (void)createDirectoryAtURI: (OFURI *)URI createParents: (bool)createParents;
#ifdef OF_HAVE_FILES
/**
* @brief Returns an array with the items in the specified directory.
*
* @note `.` and `..` are not part of the returned array.
*
* @param path The path to the directory whose items should be returned
* @return An array of OFString with the items in the specified directory
* @throw OFOpenItemFailedException Opening the directory failed
* @throw OFReadFailedException Reading from the directory failed
*/
- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path;
#endif
/**
* @brief Returns an array with the URLs of the items in the specified
* @brief Returns an array with the URIs of the items in the specified
* directory.
*
* @note `.` and `..` are not part of the returned array.
*
* @param URL The URL to the directory whose items should be returned
* @return An array with the URLs of the items in the specified directory
* @param URI The URI to the directory whose items should be returned
* @return An array with the URIs of the items in the specified directory
* @throw OFOpenItemFailedException Opening the directory failed
* @throw OFReadFailedException Reading from the directory failed
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL;
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI;
#ifdef OF_HAVE_FILES
/**
* @brief Returns an array with all subpaths of the specified directory.
*
* @note `.` and `..` (of the directory itself or any subdirectory) are not
* part of the returned array.
|
︙ | | |
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
-
+
-
+
|
* directory failed
*/
- (void)changeCurrentDirectoryPath: (OFString *)path;
/**
* @brief Changes the current working directory.
*
* @param URL The new directory to change to
* @param URI The new directory to change to
* @throw OFChangeCurrentDirectoryFailedException Changing the current working
* directory failed
*/
- (void)changeCurrentDirectoryURL: (OFURL *)URL;
- (void)changeCurrentDirectoryURI: (OFURI *)URI;
/**
* @brief Copies a file, directory or symbolic link (if supported by the OS).
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
|
︙ | | |
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
-
+
-
+
-
+
-
+
|
*/
- (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination;
#endif
/**
* @brief Copies a file, directory or symbolic link (if supported by the OS).
*
* The destination URL must have a full path, which means it must include the
* The destination URI must have a full path, which means it must include the
* name of the item.
*
* If an item already exists, the copy operation fails. This is also the case
* if a directory is copied and an item already exists in the destination
* directory.
*
* @param source The file, directory or symbolic link to copy
* @param destination The destination URL
* @param destination The destination URI
* @throw OFCopyItemFailedException Copying failed
* @throw OFCreateDirectoryFailedException Creating a destination directory
* failed
* @throw OFUnsupportedProtocolException No handler is registered for either of
* the URL's scheme
* the URI's scheme
*/
- (void)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination;
- (void)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
#ifdef OF_HAVE_FILES
/**
* @brief Moves an item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
|
︙ | | |
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
*/
- (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination;
#endif
/**
* @brief Moves an item.
*
* The destination URL must have a full path, which means it must include the
* The destination URI must have a full path, which means it must include the
* name of the item.
*
* If the destination is on a different logical device or uses a different
* scheme, the source will be copied to the destination using
* @ref copyItemAtURL:toURL: and the source removed using @ref removeItemAtURL:.
* @ref copyItemAtURI:toURI: and the source removed using @ref removeItemAtURI:.
*
* @param source The item to rename
* @param destination The new name for the item
* @throw OFMoveItemFailedException Moving failed
* @throw OFCopyItemFailedException Copying (to move between different devices)
* failed
* @throw OFRemoveItemFailedException Removing the source after copying to the
* destination (to move between different
* devices) failed
* @throw OFCreateDirectoryFailedException Creating a destination directory
* failed
* @throw OFUnsupportedProtocolException No handler is registered for either of
* the URL's scheme
* the URI's scheme
*/
- (void)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination;
- (void)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
#ifdef OF_HAVE_FILES
/**
* @brief Removes the item at the specified path.
*
* If the item at the specified path is a directory, it is removed recursively.
*
* @param path The path to the item which should be removed
* @throw OFRemoveItemFailedException Removing the item failed
*/
- (void)removeItemAtPath: (OFString *)path;
#endif
/**
* @brief Removes the item at the specified URL.
* @brief Removes the item at the specified URI.
*
* If the item at the specified URL is a directory, it is removed recursively.
* If the item at the specified URI is a directory, it is removed recursively.
*
* @param URL The URL to the item which should be removed
* @param URI The URI to the item which should be removed
* @throw OFRemoveItemFailedException Removing the item failed
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (void)removeItemAtURL: (OFURL *)URL;
- (void)removeItemAtURI: (OFURI *)URI;
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
/**
* @brief Creates a hard link for the specified item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
* This method is not available on some systems.
*
* @param source The path to the item for which a link should be created
* @param destination The path to the item which should link to the source
* @throw OFLinkItemFailedException Linking the item failed
* @throw OFNotImplementedException Hardlinks are not implemented for the
* specified URL
* specified URI
*/
- (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination;
#endif
/**
* @brief Creates a hard link for the specified item.
*
* The destination URL must have a full path, which means it must include the
* The destination URI must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URLs.
* This method is not available for all URIs.
*
* @param source The URL to the item for which a link should be created
* @param destination The URL to the item which should link to the source
* @param source The URI to the item for which a link should be created
* @param destination The URI to the item which should link to the source
* @throw OFLinkItemFailedException Linking the item failed
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
* @throw OFNotImplementedException Hardlinks are not implemented for the
* specified URL
* specified URI
*/
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination;
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
/**
* @brief Creates a symbolic link for an item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
* This method is not available on some systems.
*
* @note On Windows, this requires at least Windows Vista and administrator
* privileges!
*
* @param path The path to the item which should symbolically link to the target
* @param target The target of the symbolic link
* @throw OFCreateSymbolicLinkFailedException Creating the symbolic link failed
* @throw OFNotImplementedException Symbolic links are not implemented for the
* specified URL
* specified URI
*/
- (void)createSymbolicLinkAtPath: (OFString *)path
withDestinationPath: (OFString *)target;
#endif
/**
* @brief Creates a symbolic link for an item.
*
* The destination uRL must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URLs.
* This method is not available for all URIs.
*
* @note On Windows, this requires at least Windows Vista and administrator
* privileges!
*
* @param URL The URL to the item which should symbolically link to the target
* @param URI The URI to the item which should symbolically link to the target
* @param target The target of the symbolic link
* @throw OFUnsupportedProtocolException No handler is registered for the URL's
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* scheme
*/
- (void)createSymbolicLinkAtURL: (OFURL *)URL
- (void)createSymbolicLinkAtURI: (OFURI *)URI
withDestinationPath: (OFString *)target;
@end
@interface OFDictionary (FileAttributes)
/**
* @brief The @ref OFFileSize key from the dictionary.
*
|
︙ | | |
Modified src/OFFileManager.m
from [2c5d56a419]
to [f5483886a4].
︙ | | |
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-
-
+
+
|
#endif
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURL.h"
#import "OFURLHandler.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFChangeCurrentDirectoryFailedException.h"
#import "OFCopyItemFailedException.h"
#import "OFCreateDirectoryFailedException.h"
#import "OFGetCurrentDirectoryFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
|
︙ | | |
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
|
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
|
# endif
return [OFString stringWithCString: buffer
encoding: [OFLocale encoding]];
# endif
}
- (OFURL *)currentDirectoryURL
- (OFURI *)currentDirectoryURI
{
void *pool = objc_autoreleasePoolPush();
OFURL *ret;
OFURI *ret;
ret = [OFURL fileURLWithPath: self.currentDirectoryPath];
ret = [OFURI fileURIWithPath: self.currentDirectoryPath];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
#endif
- (OFFileAttributes)attributesOfItemAtURL: (OFURL *)URL
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI
{
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
return [URLHandler attributesOfItemAtURL: URL];
return [URIHandler attributesOfItemAtURI: URI];
}
#ifdef OF_HAVE_FILES
- (OFFileAttributes)attributesOfItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFFileAttributes ret;
ret = [self attributesOfItemAtURL: [OFURL fileURLWithPath: path]];
ret = [self attributesOfItemAtURI: [OFURI fileURIWithPath: path]];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
#endif
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURL: (OFURL *)URL
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI
{
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
[URLHandler setAttributes: attributes ofItemAtURL: URL];
[URIHandler setAttributes: attributes ofItemAtURI: URI];
}
#ifdef OF_HAVE_FILES
- (void)setAttributes: (OFFileAttributes)attributes
ofItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self setAttributes: attributes
ofItemAtURL: [OFURL fileURLWithPath: path]];
ofItemAtURI: [OFURI fileURIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
- (bool)fileExistsAtURL: (OFURL *)URL
- (bool)fileExistsAtURI: (OFURI *)URI
{
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
return [URLHandler fileExistsAtURL: URL];
return [URIHandler fileExistsAtURI: URI];
}
#ifdef OF_HAVE_FILES
- (bool)fileExistsAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
bool ret;
ret = [self fileExistsAtURL: [OFURL fileURLWithPath: path]];
ret = [self fileExistsAtURI: [OFURI fileURIWithPath: path]];
objc_autoreleasePoolPop(pool);
return ret;
}
#endif
- (bool)directoryExistsAtURL: (OFURL *)URL
- (bool)directoryExistsAtURI: (OFURI *)URI
{
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
return [URLHandler directoryExistsAtURL: URL];
return [URIHandler directoryExistsAtURI: URI];
}
#ifdef OF_HAVE_FILES
- (bool)directoryExistsAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
bool ret;
ret = [self directoryExistsAtURL: [OFURL fileURLWithPath: path]];
ret = [self directoryExistsAtURI: [OFURI fileURIWithPath: path]];
objc_autoreleasePoolPop(pool);
return ret;
}
#endif
- (void)createDirectoryAtURL: (OFURL *)URL
- (void)createDirectoryAtURI: (OFURI *)URI
{
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
[URLHandler createDirectoryAtURL: URL];
[URIHandler createDirectoryAtURI: URI];
}
- (void)createDirectoryAtURL: (OFURL *)URL
- (void)createDirectoryAtURI: (OFURI *)URI createParents: (bool)createParents
createParents: (bool)createParents
{
void *pool = objc_autoreleasePoolPush();
OFMutableURL *mutableURL;
OFMutableURI *mutableURI;
OFArray OF_GENERIC(OFString *) *components;
OFMutableArray OF_GENERIC(OFURL *) *componentURLs;
size_t componentURLsCount;
OFMutableArray OF_GENERIC(OFURI *) *componentURIs;
size_t componentURIsCount;
ssize_t i;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (!createParents) {
[self createDirectoryAtURL: URL];
[self createDirectoryAtURI: URI];
return;
}
/*
* Try blindly creating the directory first.
*
* The reason for this is that we might be sandboxed, so attempting to
* create any of the parent directories will fail, while creating the
* directory itself will work.
*/
if ([self directoryExistsAtURL: URL])
if ([self directoryExistsAtURI: URI])
return;
@try {
[self createDirectoryAtURL: URL];
[self createDirectoryAtURI: URI];
return;
} @catch (OFCreateDirectoryFailedException *e) {
/*
* If we didn't fail because any of the parents is missing,
* there is no point in trying to create the parents.
*/
if (e.errNo != ENOENT)
@throw e;
}
/*
* Because we might be sandboxed (and for remote URLs don't even know
* anything at all), we generate the URL for every component. We then
* Because we might be sandboxed (and for remote URIs don't even know
* anything at all), we generate the URI for every component. We then
* iterate them in reverse order until we find the first existing
* directory, and then create subdirectories from there.
*/
mutableURL = [[URL mutableCopy] autorelease];
mutableURL.URLEncodedPath = @"/";
components = URL.pathComponents;
componentURLs = [OFMutableArray arrayWithCapacity: components.count];
mutableURI = [[URI mutableCopy] autorelease];
mutableURI.percentEncodedPath = @"/";
components = URI.pathComponents;
componentURIs = [OFMutableArray arrayWithCapacity: components.count];
for (OFString *component in components) {
[mutableURL appendPathComponent: component];
[mutableURI appendPathComponent: component];
if (![mutableURL.URLEncodedPath isEqual: @"/"])
[componentURLs addObject:
[[mutableURL copy] autorelease]];
if (![mutableURI.percentEncodedPath isEqual: @"/"])
[componentURIs addObject:
[[mutableURI copy] autorelease]];
}
componentURLsCount = componentURLs.count;
for (i = componentURLsCount - 1; i > 0; i--) {
if ([self directoryExistsAtURL:
[componentURLs objectAtIndex: i]])
componentURIsCount = componentURIs.count;
for (i = componentURIsCount - 1; i > 0; i--) {
if ([self directoryExistsAtURI:
[componentURIs objectAtIndex: i]])
break;
}
if (++i == (ssize_t)componentURLsCount) {
if (++i == (ssize_t)componentURIsCount) {
/*
* The URL exists, even though before we made sure it did not.
* The URI exists, even though before we made sure it did not.
* That means it was created in the meantime by something else,
* so we're done here.
*/
objc_autoreleasePoolPop(pool);
return;
}
for (; i < (ssize_t)componentURLsCount; i++)
[self createDirectoryAtURL: [componentURLs objectAtIndex: i]];
for (; i < (ssize_t)componentURIsCount; i++)
[self createDirectoryAtURI: [componentURIs objectAtIndex: i]];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_FILES
- (void)createDirectoryAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self createDirectoryAtURL: [OFURL fileURLWithPath: path]];
[self createDirectoryAtURI: [OFURI fileURIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
- (void)createDirectoryAtPath: (OFString *)path
createParents: (bool)createParents
{
void *pool = objc_autoreleasePoolPush();
[self createDirectoryAtURL: [OFURL fileURLWithPath: path]
[self createDirectoryAtURI: [OFURI fileURIWithPath: path]
createParents: createParents];
objc_autoreleasePoolPop(pool);
}
#endif
- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI
{
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
return [URLHandler contentsOfDirectoryAtURL: URL];
return [URIHandler contentsOfDirectoryAtURI: URI];
}
#ifdef OF_HAVE_FILES
- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFArray OF_GENERIC(OFURL *) *URLs;
OFArray OF_GENERIC(OFURI *) *URIs;
OFMutableArray OF_GENERIC(OFString *) *ret;
URLs = [self contentsOfDirectoryAtURL: [OFURL fileURLWithPath: path]];
ret = [OFMutableArray arrayWithCapacity: URLs.count];
URIs = [self contentsOfDirectoryAtURI: [OFURI fileURIWithPath: path]];
ret = [OFMutableArray arrayWithCapacity: URIs.count];
for (OFURL *URL in URLs)
[ret addObject: URL.lastPathComponent];
for (OFURI *URI in URIs)
[ret addObject: URI.lastPathComponent];
[ret makeImmutable];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
|
︙ | | |
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
|
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
|
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
|
if (status != 0)
@throw [OFChangeCurrentDirectoryFailedException
exceptionWithPath: path
errNo: errno];
# endif
}
- (void)changeCurrentDirectoryURL: (OFURL *)URL
- (void)changeCurrentDirectoryURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
[self changeCurrentDirectoryPath: URL.fileSystemRepresentation];
[self changeCurrentDirectoryPath: URI.fileSystemRepresentation];
objc_autoreleasePoolPop(pool);
}
- (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self copyItemAtURL: [OFURL fileURLWithPath: source]
toURL: [OFURL fileURLWithPath: destination]];
[self copyItemAtURI: [OFURI fileURIWithPath: source]
toURI: [OFURI fileURIWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (void)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
void *pool;
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
OFFileAttributes attributes;
OFFileAttributeType type;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if ((URLHandler = [OFURLHandler handlerForURL: source]) == nil)
if ((URIHandler = [OFURIHandler handlerForURI: source]) == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: source];
exceptionWithURI: source];
if ([URLHandler copyItemAtURL: source toURL: destination])
if ([URIHandler copyItemAtURI: source toURI: destination])
return;
if ([self fileExistsAtURL: destination])
if ([self fileExistsAtURI: destination])
@throw [OFCopyItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: EEXIST];
@try {
attributes = [self attributesOfItemAtURL: source];
attributes = [self attributesOfItemAtURI: source];
} @catch (OFGetItemAttributesFailedException *e) {
@throw [OFCopyItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: e.errNo];
}
type = attributes.fileType;
if ([type isEqual: OFFileTypeDirectory]) {
OFArray OF_GENERIC(OFURL *) *contents;
OFArray OF_GENERIC(OFURI *) *contents;
@try {
[self createDirectoryAtURL: destination];
[self createDirectoryAtURI: destination];
@try {
OFFileAttributeKey key = OFFilePOSIXPermissions;
OFNumber *permissions =
[attributes objectForKey: key];
OFFileAttributes destinationAttributes;
if (permissions != nil) {
destinationAttributes = [OFDictionary
dictionaryWithObject: permissions
forKey: key];
[self
setAttributes: destinationAttributes
ofItemAtURL: destination];
ofItemAtURI: destination];
}
} @catch (OFNotImplementedException *e) {
}
contents = [self contentsOfDirectoryAtURL: source];
contents = [self contentsOfDirectoryAtURI: source];
} @catch (id e) {
/*
* Only convert exceptions to OFCopyItemFailedException
* that have an errNo property. This covers all I/O
* related exceptions from the operations used to copy
* an item, all others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFCopyItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: [e errNo]];
@throw e;
}
for (OFURL *item in contents) {
for (OFURI *item in contents) {
void *pool2 = objc_autoreleasePoolPush();
OFURL *destinationURL = [destination
URLByAppendingPathComponent:
OFURI *destinationURI = [destination
URIByAppendingPathComponent:
item.lastPathComponent];
[self copyItemAtURL: item toURL: destinationURL];
[self copyItemAtURI: item toURI: destinationURI];
objc_autoreleasePoolPop(pool2);
}
} else if ([type isEqual: OFFileTypeRegular]) {
size_t pageSize = [OFSystemInfo pageSize];
OFStream *sourceStream = nil;
OFStream *destinationStream = nil;
char *buffer;
buffer = OFAllocMemory(1, pageSize);
@try {
sourceStream = [OFURLHandler openItemAtURL: source
sourceStream = [OFURIHandler openItemAtURI: source
mode: @"r"];
destinationStream = [OFURLHandler
openItemAtURL: destination
destinationStream = [OFURIHandler
openItemAtURI: destination
mode: @"w"];
while (!sourceStream.atEndOfStream) {
size_t length;
length = [sourceStream
readIntoBuffer: buffer
|
︙ | | |
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
|
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
|
if (permissions != nil) {
destinationAttributes = [OFDictionary
dictionaryWithObject: permissions
forKey: key];
[self
setAttributes: destinationAttributes
ofItemAtURL: destination];
ofItemAtURI: destination];
}
} @catch (OFNotImplementedException *e) {
}
} @catch (id e) {
/*
* Only convert exceptions to OFCopyItemFailedException
* that have an errNo property. This covers all I/O
* related exceptions from the operations used to copy
* an item, all others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFCopyItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: [e errNo]];
@throw e;
} @finally {
[sourceStream close];
[destinationStream close];
OFFreeMemory(buffer);
}
} else if ([type isEqual: OFFileTypeSymbolicLink]) {
@try {
OFString *linkDestination =
attributes.fileSymbolicLinkDestination;
[self createSymbolicLinkAtURL: destination
[self createSymbolicLinkAtURI: destination
withDestinationPath: linkDestination];
} @catch (id e) {
/*
* Only convert exceptions to OFCopyItemFailedException
* that have an errNo property. This covers all I/O
* related exceptions from the operations used to copy
* an item, all others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFCopyItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: [e errNo]];
@throw e;
}
} else
@throw [OFCopyItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: EINVAL];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_FILES
- (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self moveItemAtURL: [OFURL fileURLWithPath: source]
toURL: [OFURL fileURLWithPath: destination]];
[self moveItemAtURI: [OFURI fileURIWithPath: source]
toURI: [OFURI fileURIWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (void)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
void *pool;
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if ((URLHandler = [OFURLHandler handlerForURL: source]) == nil)
if ((URIHandler = [OFURIHandler handlerForURI: source]) == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: source];
exceptionWithURI: source];
@try {
if ([URLHandler moveItemAtURL: source toURL: destination])
if ([URIHandler moveItemAtURI: source toURI: destination])
return;
} @catch (OFMoveItemFailedException *e) {
if (e.errNo != EXDEV)
@throw e;
}
if ([self fileExistsAtURL: destination])
if ([self fileExistsAtURI: destination])
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: EEXIST];
@try {
[self copyItemAtURL: source toURL: destination];
[self copyItemAtURI: source toURI: destination];
} @catch (OFCopyItemFailedException *e) {
[self removeItemAtURL: destination];
[self removeItemAtURI: destination];
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: e.errNo];
}
@try {
[self removeItemAtURL: source];
[self removeItemAtURI: source];
} @catch (OFRemoveItemFailedException *e) {
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: e.errNo];
}
objc_autoreleasePoolPop(pool);
}
- (void)removeItemAtURL: (OFURL *)URL
- (void)removeItemAtURI: (OFURI *)URI
{
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
[URLHandler removeItemAtURL: URL];
[URIHandler removeItemAtURI: URI];
}
#ifdef OF_HAVE_FILES
- (void)removeItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self removeItemAtURL: [OFURL fileURLWithPath: path]];
[self removeItemAtURI: [OFURI fileURIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
void *pool = objc_autoreleasePoolPush();
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
if (![destination.scheme isEqual: source.scheme])
@throw [OFInvalidArgumentException exception];
URLHandler = [OFURLHandler handlerForURL: source];
URIHandler = [OFURIHandler handlerForURI: source];
if (URLHandler == nil)
if (URIHandler == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: source];
exceptionWithURI: source];
[URLHandler linkItemAtURL: source toURL: destination];
[URIHandler linkItemAtURI: source toURI: destination];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
- (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self linkItemAtURL: [OFURL fileURLWithPath: source]
toURL: [OFURL fileURLWithPath: destination]];
[self linkItemAtURI: [OFURI fileURIWithPath: source]
toURI: [OFURI fileURIWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)createSymbolicLinkAtURL: (OFURL *)URL
- (void)createSymbolicLinkAtURI: (OFURI *)URI
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
OFURLHandler *URLHandler;
OFURIHandler *URIHandler;
if (URL == nil || target == nil)
if (URI == nil || target == nil)
@throw [OFInvalidArgumentException exception];
URLHandler = [OFURLHandler handlerForURL: URL];
URIHandler = [OFURIHandler handlerForURI: URI];
if (URLHandler == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
if (URIHandler == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
[URLHandler createSymbolicLinkAtURL: URL withDestinationPath: target];
[URIHandler createSymbolicLinkAtURI: URI withDestinationPath: target];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
- (void)createSymbolicLinkAtPath: (OFString *)path
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
[self createSymbolicLinkAtURL: [OFURL fileURLWithPath: path]
[self createSymbolicLinkAtURI: [OFURI fileURIWithPath: path]
withDestinationPath: target];
objc_autoreleasePoolPop(pool);
}
#endif
@end
@implementation OFDefaultFileManager
|
︙ | | |
Renamed and modified
src/OFFileURLHandler.h
[bc6fd1985b]
to src/OFFileURIHandler.h
[24ec18a27d].
︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
+
-
+
|
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURLHandler.h"
#import "OFURIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFFileURLHandler: OFURLHandler
@interface OFFileURIHandler: OFURIHandler
+ (bool)of_directoryExistsAtPath: (OFString *)path OF_DIRECT;
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFFileURLHandler.m
[cc6f47538b]
to src/OFFileURIHandler.m
[85f56ad9ce].
︙ | | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
-
+
-
+
|
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#endif
#import "OFFileURLHandler.h"
#import "OFFileURIHandler.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFSystemInfo.h"
#import "OFURL.h"
#import "OFURI.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
#import "OFCreateDirectoryFailedException.h"
#import "OFCreateSymbolicLinkFailedException.h"
|
︙ | | |
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
-
+
-
+
-
+
-
+
-
+
-
+
|
# endif
#endif
}
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
static void
setSymbolicLinkDestinationAttribute(OFMutableFileAttributes attributes,
OFURL *URL)
OFURI *URI)
{
OFString *path = URL.fileSystemRepresentation;
OFString *path = URI.fileSystemRepresentation;
# ifndef OF_WINDOWS
OFStringEncoding encoding = [OFLocale encoding];
char destinationC[PATH_MAX];
ssize_t length;
OFString *destination;
length = readlink([path cStringWithEncoding: encoding], destinationC,
PATH_MAX);
if (length < 0)
@throw [OFGetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: errno];
destination = [OFString stringWithCString: destinationC
encoding: encoding
length: length];
[attributes setObject: destination
forKey: OFFileSymbolicLinkDestination];
# else
HANDLE handle;
OFString *destination;
if (createSymbolicLinkWFuncPtr == NULL)
return;
if ((handle = CreateFileW(path.UTF16String, 0, (FILE_SHARE_READ |
FILE_SHARE_WRITE), NULL, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE)
@throw [OFGetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: lastError()];
@try {
union {
char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
REPARSE_DATA_BUFFER data;
} buffer;
DWORD size;
wchar_t *tmp;
if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0,
buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size,
NULL))
@throw [OFGetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: lastError()];
if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK)
@throw [OFGetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: lastError()];
# define slrb buffer.data.SymbolicLinkReparseBuffer
tmp = slrb.PathBuffer +
(slrb.SubstituteNameOffset / sizeof(wchar_t));
destination = [OFString
|
︙ | | |
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
-
+
-
+
|
} @finally {
CloseHandle(handle);
}
# endif
}
#endif
@implementation OFFileURLHandler
@implementation OFFileURIHandler
+ (void)initialize
{
#ifdef OF_WINDOWS
HMODULE module;
#endif
if (self != [OFFileURLHandler class])
if (self != [OFFileURIHandler class])
return;
#if defined(OF_FILE_MANAGER_SUPPORTS_OWNER) && defined(OF_HAVE_THREADS)
passwdMutex = [[OFMutex alloc] init];
atexit(releasePasswdMutex);
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
|
︙ | | |
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
|
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
if (statWrapper(path, &s) != 0)
return false;
return S_ISDIR(s.st_mode);
}
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [[OFFile alloc]
initWithPath: URL.fileSystemRepresentation
initWithPath: URI.fileSystemRepresentation
mode: mode];
objc_autoreleasePoolPop(pool);
return [file autorelease];
}
- (OFFileAttributes)attributesOfItemAtURL: (OFURL *)URL
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI
{
OFMutableFileAttributes ret = [OFMutableDictionary dictionary];
void *pool = objc_autoreleasePoolPush();
OFString *path;
int error;
Stat s;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (![[URL scheme] isEqual: _scheme])
if (![[URI scheme] isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URL.fileSystemRepresentation;
path = URI.fileSystemRepresentation;
if ((error = lstatWrapper(path, &s)) != 0)
@throw [OFGetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: error];
if (s.st_size < 0)
@throw [OFOutOfRangeException exception];
[ret setObject: [NSNumber numberWithUnsignedLongLong: s.st_size]
forKey: OFFileSize];
setTypeAttribute(ret, &s);
[ret setObject: [NSNumber numberWithUnsignedLong: s.st_mode]
forKey: OFFilePOSIXPermissions];
setOwnerAndGroupAttributes(ret, &s);
setDateAttributes(ret, &s);
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
if (S_ISLNK(s.st_mode))
setSymbolicLinkDestinationAttribute(ret, URL);
setSymbolicLinkDestinationAttribute(ret, URI);
#endif
objc_autoreleasePoolPop(pool);
return ret;
}
- (void)of_setLastAccessDate: (OFDate *)lastAccessDate
andModificationDate: (OFDate *)modificationDate
ofItemAtURL: (OFURL *)URL
ofItemAtURI: (OFURI *)URI
attributes: (OFFileAttributes)attributes OF_DIRECT
{
OFString *path = URL.fileSystemRepresentation;
OFString *path = URI.fileSystemRepresentation;
OFFileAttributeKey attributeKey = (modificationDate != nil
? OFFileModificationDate : OFFileLastAccessDate);
if (lastAccessDate == nil)
lastAccessDate = modificationDate;
if (modificationDate == nil)
modificationDate = lastAccessDate;
#if defined(OF_WINDOWS)
if (_wutime64FuncPtr != NULL) {
struct __utimbuf64 times = {
.actime =
(__time64_t)lastAccessDate.timeIntervalSince1970,
.modtime =
(__time64_t)modificationDate.timeIntervalSince1970
};
if (_wutime64FuncPtr([path UTF16String], ×) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
} else {
struct _utimbuf times = {
.actime = (time_t)lastAccessDate.timeIntervalSince1970,
.modtime =
(time_t)modificationDate.timeIntervalSince1970
};
int status;
if ([OFSystemInfo isWindowsNT])
status = _wutime([path UTF16String], ×);
else
status = _utime(
[path cStringWithEncoding: [OFLocale encoding]],
×);
if (status != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
}
#elif defined(OF_AMIGAOS)
/* AmigaOS does not support access time. */
OFTimeInterval modificationTime =
|
︙ | | |
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
|
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
|
-
+
|
if (!SetDate([path cStringWithEncoding: [OFLocale encoding]],
&date) != 0)
# else
if (!SetFileDate([path cStringWithEncoding: [OFLocale encoding]],
&date) != 0)
# endif
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: attributeKey
errNo: lastError()];
#else
OFTimeInterval lastAccessTime = lastAccessDate.timeIntervalSince1970;
OFTimeInterval modificationTime =
modificationDate.timeIntervalSince1970;
|
︙ | | |
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
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
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
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
1047
1048
1049
1050
1051
1052
1053
|
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
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
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
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
1047
1048
1049
1050
1051
1052
1053
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
|
.tv_usec = (int)((modificationTime - times[1].tv_sec) *
1000000)
},
};
if (utimes([path cStringWithEncoding: [OFLocale encoding]], times) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
#endif
}
- (void)of_setPOSIXPermissions: (OFNumber *)permissions
ofItemAtURL: (OFURL *)URL
ofItemAtURI: (OFURI *)URI
attributes: (OFFileAttributes)attributes OF_DIRECT
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
mode_t mode = (mode_t)permissions.unsignedLongValue;
OFString *path = URL.fileSystemRepresentation;
OFString *path = URI.fileSystemRepresentation;
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wchmod(path.UTF16String, mode);
else
# endif
status = chmod(
[path cStringWithEncoding: [OFLocale encoding]], mode);
if (status != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: OFFilePOSIXPermissions
errNo: errno];
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (void)of_setOwnerAccountName: (OFString *)owner
andGroupOwnerAccountName: (OFString *)group
ofItemAtURL: (OFURL *)URL
ofItemAtURI: (OFURI *)URI
attributeKey: (OFFileAttributeKey)attributeKey
attributes: (OFFileAttributes)attributes OF_DIRECT
{
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
OFString *path = URL.fileSystemRepresentation;
OFString *path = URI.fileSystemRepresentation;
uid_t uid = -1;
gid_t gid = -1;
OFStringEncoding encoding;
if (owner == nil && group == nil)
@throw [OFInvalidArgumentException exception];
encoding = [OFLocale encoding];
# ifdef OF_HAVE_THREADS
[passwdMutex lock];
@try {
# endif
if (owner != nil) {
struct passwd *passwd;
if ((passwd = getpwnam([owner
cStringWithEncoding: encoding])) == NULL)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
uid = passwd->pw_uid;
}
if (group != nil) {
struct group *group_;
if ((group_ = getgrnam([group
cStringWithEncoding: encoding])) == NULL)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
gid = group_->gr_gid;
}
# ifdef OF_HAVE_THREADS
} @finally {
[passwdMutex unlock];
}
# endif
if (chown([path cStringWithEncoding: encoding], uid, gid) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
exceptionWithURI: URI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURL: (OFURL *)URL
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
OFEnumerator OF_GENERIC(OFFileAttributeKey) *keyEnumerator;
OFEnumerator *objectEnumerator;
OFFileAttributeKey key;
id object;
OFDate *lastAccessDate, *modificationDate;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (![URL.scheme isEqual: _scheme])
if (![URI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
keyEnumerator = [attributes keyEnumerator];
objectEnumerator = [attributes objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
if ([key isEqual: OFFileModificationDate] ||
[key isEqual: OFFileLastAccessDate])
continue;
else if ([key isEqual: OFFilePOSIXPermissions])
[self of_setPOSIXPermissions: object
ofItemAtURL: URL
ofItemAtURI: URI
attributes: attributes];
else if ([key isEqual: OFFileOwnerAccountName])
[self of_setOwnerAccountName: object
andGroupOwnerAccountName: nil
ofItemAtURL: URL
ofItemAtURI: URI
attributeKey: key
attributes: attributes];
else if ([key isEqual: OFFileGroupOwnerAccountName])
[self of_setOwnerAccountName: nil
andGroupOwnerAccountName: object
ofItemAtURL: URL
ofItemAtURI: URI
attributeKey: key
attributes: attributes];
else
@throw [OFNotImplementedException
exceptionWithSelector: _cmd
object: self];
}
lastAccessDate = [attributes objectForKey: OFFileLastAccessDate];
modificationDate = [attributes objectForKey: OFFileModificationDate];
if (lastAccessDate != nil || modificationDate != nil)
[self of_setLastAccessDate: lastAccessDate
andModificationDate: modificationDate
ofItemAtURL: URL
ofItemAtURI: URI
attributes: attributes];
objc_autoreleasePoolPop(pool);
}
- (bool)fileExistsAtURL: (OFURL *)URL
- (bool)fileExistsAtURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
Stat s;
bool ret;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (![URL.scheme isEqual: _scheme])
if (![URI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
if (statWrapper(URL.fileSystemRepresentation, &s) != 0) {
if (statWrapper(URI.fileSystemRepresentation, &s) != 0) {
objc_autoreleasePoolPop(pool);
return false;
}
ret = S_ISREG(s.st_mode);
objc_autoreleasePoolPop(pool);
return ret;
}
- (bool)directoryExistsAtURL: (OFURL *)URL
- (bool)directoryExistsAtURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
Stat s;
bool ret;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (![URL.scheme isEqual: _scheme])
if (![URI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
if (statWrapper(URL.fileSystemRepresentation, &s) != 0) {
if (statWrapper(URI.fileSystemRepresentation, &s) != 0) {
objc_autoreleasePoolPop(pool);
return false;
}
ret = S_ISDIR(s.st_mode);
objc_autoreleasePoolPop(pool);
return ret;
}
- (void)createDirectoryAtURL: (OFURL *)URL
- (void)createDirectoryAtURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (![URL.scheme isEqual: _scheme])
if (![URI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URL.fileSystemRepresentation;
path = URI.fileSystemRepresentation;
#if defined(OF_WINDOWS)
int status;
if ([OFSystemInfo isWindowsNT])
status = _wmkdir(path.UTF16String);
else
status = _mkdir(
[path cStringWithEncoding: [OFLocale encoding]]);
if (status != 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: errno];
#elif defined(OF_AMIGAOS)
BPTR lock;
if ((lock = CreateDir(
[path cStringWithEncoding: [OFLocale encoding]])) == 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: lastError()];
UnLock(lock);
#else
if (mkdir([path cStringWithEncoding: [OFLocale encoding]], 0777) != 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: errno];
#endif
objc_autoreleasePoolPop(pool);
}
- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI
{
OFMutableArray *URLs = [OFMutableArray array];
OFMutableArray *URIs = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
OFString *path;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (![URL.scheme isEqual: _scheme])
if (![URI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URL.fileSystemRepresentation;
path = URI.fileSystemRepresentation;
#if defined(OF_WINDOWS)
HANDLE handle;
path = [path stringByAppendingString: @"\\*"];
if ([OFSystemInfo isWindowsNT]) {
WIN32_FIND_DATAW fd;
if ((handle = FindFirstFileW(path.UTF16String,
&fd)) == INVALID_HANDLE_VALUE)
@throw [OFOpenItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
mode: nil
errNo: lastError()];
@try {
do {
OFString *file;
if (wcscmp(fd.cFileName, L".") == 0 ||
wcscmp(fd.cFileName, L"..") == 0)
continue;
file = [[OFString alloc]
initWithUTF16String: fd.cFileName];
@try {
[URLs addObject: [URL
URLByAppendingPathComponent: file]];
[URIs addObject: [URI
URIByAppendingPathComponent: file]];
} @finally {
[file release];
}
} while (FindNextFileW(handle, &fd));
if (GetLastError() != ERROR_NO_MORE_FILES)
@throw [OFReadFailedException
|
︙ | | |
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
|
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
|
-
+
-
-
+
+
|
OFStringEncoding encoding = [OFLocale encoding];
WIN32_FIND_DATA fd;
if ((handle = FindFirstFileA(
[path cStringWithEncoding: encoding], &fd)) ==
INVALID_HANDLE_VALUE)
@throw [OFOpenItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
mode: nil
errNo: lastError()];
@try {
do {
OFString *file;
if (strcmp(fd.cFileName, ".") == 0 ||
strcmp(fd.cFileName, "..") == 0)
continue;
file = [[OFString alloc]
initWithCString: fd.cFileName
encoding: encoding];
@try {
[URLs addObject: [URL
URLByAppendingPathComponent: file]];
[URIs addObject: [URI
URIByAppendingPathComponent: file]];
} @finally {
[file release];
}
} while (FindNextFileA(handle, &fd));
if (GetLastError() != ERROR_NO_MORE_FILES)
@throw [OFReadFailedException
|
︙ | | |
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
|
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
|
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
|
#elif defined(OF_AMIGAOS)
OFStringEncoding encoding = [OFLocale encoding];
BPTR lock;
if ((lock = Lock([path cStringWithEncoding: encoding],
SHARED_LOCK)) == 0)
@throw [OFOpenItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
mode: nil
errNo: lastError()];
@try {
# ifdef OF_AMIGAOS4
struct ExamineData *ed;
APTR context;
if ((context = ObtainDirContextTags(EX_FileLockInput, lock,
EX_DoCurrentDir, TRUE, EX_DataFields, EXF_NAME,
TAG_END)) == NULL)
@throw [OFOpenItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
mode: nil
errNo: lastError()];
@try {
while ((ed = ExamineDir(context)) != NULL) {
OFString *file = [[OFString alloc]
initWithCString: ed->Name
encoding: encoding];
@try {
[URLs addObject: [URL
URLByAppendingPathComponent: file]];
[URIs addObject: [URI
URIByAppendingPathComponent: file]];
} @finally {
[file release];
}
}
} @finally {
ReleaseDirContext(context);
}
# else
struct FileInfoBlock fib;
if (!Examine(lock, &fib))
@throw [OFOpenItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
mode: nil
errNo: lastError()];
while (ExNext(lock, &fib)) {
OFString *file = [[OFString alloc]
initWithCString: fib.fib_FileName
encoding: encoding];
@try {
[URLs addObject:
[URL URLByAppendingPathComponent: file]];
[URIs addObject:
[URI URIByAppendingPathComponent: file]];
} @finally {
[file release];
}
}
# endif
if (IoErr() != ERROR_NO_MORE_ENTRIES)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: 0
errNo: lastError()];
} @finally {
UnLock(lock);
}
#else
OFStringEncoding encoding = [OFLocale encoding];
DIR *dir;
if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL)
@throw [OFOpenItemFailedException exceptionWithURL: URL
@throw [OFOpenItemFailedException exceptionWithURI: URI
mode: nil
errNo: errno];
# if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS)
@try {
[readdirMutex lock];
} @catch (id e) {
|
︙ | | |
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
|
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
|
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
|
if (strcmp(dirent->d_name, ".") == 0 ||
strcmp(dirent->d_name, "..") == 0)
continue;
file = [[OFString alloc] initWithCString: dirent->d_name
encoding: encoding];
@try {
[URLs addObject:
[URL URLByAppendingPathComponent: file]];
[URIs addObject:
[URI URIByAppendingPathComponent: file]];
} @finally {
[file release];
}
}
} @finally {
closedir(dir);
# if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS)
[readdirMutex unlock];
# endif
}
#endif
[URLs makeImmutable];
[URIs makeImmutable];
objc_autoreleasePoolPop(pool);
return URLs;
return URIs;
}
- (void)removeItemAtURL: (OFURL *)URL
- (void)removeItemAtURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
int error;
Stat s;
if (URL == nil)
if (URI == nil)
@throw [OFInvalidArgumentException exception];
if (![URL.scheme isEqual: _scheme])
if (![URI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URL.fileSystemRepresentation;
path = URI.fileSystemRepresentation;
if ((error = lstatWrapper(path, &s)) != 0)
@throw [OFRemoveItemFailedException exceptionWithURL: URL
@throw [OFRemoveItemFailedException exceptionWithURI: URI
errNo: error];
if (S_ISDIR(s.st_mode)) {
OFArray OF_GENERIC(OFURL *) *contents;
OFArray OF_GENERIC(OFURI *) *contents;
@try {
contents = [self contentsOfDirectoryAtURL: URL];
contents = [self contentsOfDirectoryAtURI: URI];
} @catch (id e) {
/*
* Only convert exceptions to
* OFRemoveItemFailedException that have an errNo
* property. This covers all I/O related exceptions
* from the operations used to remove an item, all
* others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFRemoveItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: [e errNo]];
@throw e;
}
for (OFURL *item in contents) {
for (OFURI *item in contents) {
void *pool2 = objc_autoreleasePoolPush();
[self removeItemAtURL: item];
[self removeItemAtURI: item];
objc_autoreleasePoolPop(pool2);
}
#ifndef OF_AMIGAOS
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wrmdir(path.UTF16String);
else
# endif
status = rmdir(
[path cStringWithEncoding: [OFLocale encoding]]);
if (status != 0)
@throw [OFRemoveItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: errno];
} else {
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wunlink(path.UTF16String);
else
# endif
status = unlink(
[path cStringWithEncoding: [OFLocale encoding]]);
if (status != 0)
@throw [OFRemoveItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: errno];
#endif
}
#ifdef OF_AMIGAOS
if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]]))
@throw [OFRemoveItemFailedException
exceptionWithURL: URL
exceptionWithURI: URI
errNo: lastError()];
#endif
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
void *pool = objc_autoreleasePoolPush();
OFString *sourcePath, *destinationPath;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
if (![source.scheme isEqual: _scheme] ||
![destination.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
sourcePath = source.fileSystemRepresentation;
destinationPath = destination.fileSystemRepresentation;
# ifndef OF_WINDOWS
OFStringEncoding encoding = [OFLocale encoding];
if (link([sourcePath cStringWithEncoding: encoding],
[destinationPath cStringWithEncoding: encoding]) != 0)
@throw [OFLinkItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: errno];
# else
if (createHardLinkWFuncPtr == NULL)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
if (!createHardLinkWFuncPtr(destinationPath.UTF16String,
sourcePath.UTF16String, NULL))
@throw [OFLinkItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: lastError()];
# endif
objc_autoreleasePoolPop(pool);
}
#endif
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
- (void)createSymbolicLinkAtURL: (OFURL *)URL
- (void)createSymbolicLinkAtURI: (OFURI *)URI
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
if (URL == nil || target == nil)
if (URI == nil || target == nil)
@throw [OFInvalidArgumentException exception];
if (![URL.scheme isEqual: _scheme])
if (![URI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URL.fileSystemRepresentation;
path = URI.fileSystemRepresentation;
# ifndef OF_WINDOWS
OFStringEncoding encoding = [OFLocale encoding];
if (symlink([target cStringWithEncoding: encoding],
[path cStringWithEncoding: encoding]) != 0)
@throw [OFCreateSymbolicLinkFailedException
exceptionWithURL: URL
exceptionWithURI: URI
target: target
errNo: errno];
# else
if (createSymbolicLinkWFuncPtr == NULL)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
if (!createSymbolicLinkWFuncPtr(path.UTF16String, target.UTF16String,
0))
@throw [OFCreateSymbolicLinkFailedException
exceptionWithURL: URL
exceptionWithURI: URI
target: target
errNo: lastError()];
# endif
objc_autoreleasePoolPop(pool);
}
#endif
- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (bool)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
void *pool;
if (![source.scheme isEqual: _scheme] ||
![destination.scheme isEqual: _scheme])
return false;
if ([self fileExistsAtURL: destination])
if ([self fileExistsAtURI: destination])
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: EEXIST];
pool = objc_autoreleasePoolPush();
#ifdef OF_AMIGAOS
OFStringEncoding encoding = [OFLocale encoding];
if (!Rename([source.fileSystemRepresentation
cStringWithEncoding: encoding],
[destination.fileSystemRepresentation
cStringWithEncoding: encoding]))
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: lastError()];
#else
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wrename(source.fileSystemRepresentation.UTF16String,
|
︙ | | |
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
|
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
|
-
-
+
+
|
cStringWithEncoding: encoding]);
# ifdef OF_WINDOWS
}
# endif
if (status != 0)
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
exceptionWithSourceURI: source
destinationURI: destination
errNo: errno];
#endif
objc_autoreleasePoolPop(pool);
return true;
}
@end
|
Modified src/OFHTTPClient.h
from [d00f0b1c33]
to [cad337925c].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
|
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFHTTPClient;
@class OFHTTPRequest;
@class OFHTTPResponse;
@class OFStream;
@class OFTCPSocket;
@class OFTLSStream;
@class OFURL;
@class OFURI;
/**
* @protocol OFHTTPClientDelegate OFHTTPClient.h ObjFW/OFHTTPClient.h
*
* @brief A delegate for OFHTTPClient.
*/
@protocol OFHTTPClientDelegate <OFObject>
|
︙ | | |
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
-
+
-
+
-
+
-
+
|
* to detect a redirect.
*
* This callback will only be called if the OFHTTPClient will follow a
* redirect. If the maximum number of redirects has been reached already, this
* callback will not be called.
*
* @param client The OFHTTPClient which wants to follow a redirect
* @param URL The URL to which it will follow a redirect
* @param URI The URI to which it will follow a redirect
* @param statusCode The status code for the redirection
* @param request The request for which the OFHTTPClient wants to redirect.
* You are allowed to change the request's headers from this
* callback and they will be used when following the redirect
* (e.g. to set the cookies for the new URL), however, keep in
* (e.g. to set the cookies for the new URI), however, keep in
* mind that this will change the request you originally passed.
* @param response The response indicating the redirect
* @return A boolean whether the OFHTTPClient should follow the redirect
*/
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirect: (OFURL *)URL
shouldFollowRedirect: (OFURI *)URI
statusCode: (short)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response;
@end
/**
* @class OFHTTPClient OFHTTPClient.h ObjFW/OFHTTPClient.h
*
* @brief A class for performing HTTP requests.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFHTTPClient: OFObject
{
#ifdef OF_HTTP_CLIENT_M
@public
#endif
OFObject <OFHTTPClientDelegate> *_Nullable _delegate;
bool _allowsInsecureRedirects, _inProgress;
OFStream *_Nullable _stream;
OFURL *_Nullable _lastURL;
OFURI *_Nullable _lastURI;
bool _lastWasHEAD;
OFHTTPResponse *_Nullable _lastResponse;
}
/**
* @brief The delegate of the HTTP request.
*/
|
︙ | | |
Modified src/OFHTTPClient.m
from [b873afdcee]
to [5fbd446b75].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
+
|
#import "OFHTTPResponse.h"
#import "OFKernelEventObserver.h"
#import "OFNumber.h"
#import "OFRunLoop.h"
#import "OFString.h"
#import "OFTCPSocket.h"
#import "OFTLSStream.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFAlreadyConnectedException.h"
#import "OFHTTPRequestFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidServerResponseException.h"
|
︙ | | |
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
+
|
@end
static OFString *
constructRequestString(OFHTTPRequest *request)
{
void *pool = objc_autoreleasePoolPush();
OFHTTPRequestMethod method = request.method;
OFURL *URL = request.URL;
OFURI *URI = request.URI;
OFString *path;
OFString *user = URL.user, *password = URL.password;
OFString *user = URI.user, *password = URI.password;
OFMutableString *requestString;
OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers;
bool hasContentLength, chunked;
OFEnumerator OF_GENERIC(OFString *) *keyEnumerator, *objectEnumerator;
OFString *key, *object;
if (URL.path != nil)
path = URL.URLEncodedPath;
if (URI.path != nil)
path = URI.percentEncodedPath;
else
path = @"/";
requestString = [OFMutableString stringWithFormat:
@"%s %@", OFHTTPRequestMethodName(method), path];
if (URL.query != nil) {
if (URI.query != nil) {
[requestString appendString: @"?"];
[requestString appendString: URL.URLEncodedQuery];
[requestString appendString: URI.percentEncodedQuery];
}
[requestString appendString: @" HTTP/"];
[requestString appendString: request.protocolVersionString];
[requestString appendString: @"\r\n"];
headers = [[request.headers mutableCopy] autorelease];
if (headers == nil)
headers = [OFMutableDictionary dictionary];
if ([headers objectForKey: @"Host"] == nil) {
OFNumber *port = URL.port;
OFNumber *port = URI.port;
if (port != nil) {
OFString *host = [OFString stringWithFormat:
@"%@:%@", URL.URLEncodedHost, port];
@"%@:%@", URI.percentEncodedHost, port];
[headers setObject: host forKey: @"Host"];
} else
[headers setObject: URL.URLEncodedHost forKey: @"Host"];
[headers setObject: URI.percentEncodedHost
forKey: @"Host"];
}
if ((user.length > 0 || password.length > 0) &&
[headers objectForKey: @"Authorization"] == nil) {
OFMutableData *authorizationData = [OFMutableData data];
OFString *authorization;
|
︙ | | |
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
-
+
|
didPerformRequest: _request
response: nil
exception: exception];
}
- (void)createResponseWithStreamOrThrow: (OFStream *)stream
{
OFURL *URL = _request.URL;
OFURI *URI = _request.URI;
OFHTTPClientResponse *response;
OFString *connectionHeader;
bool keepAlive;
OFString *location;
id exception;
response = [[[OFHTTPClientResponse alloc] initWithStream: stream]
|
︙ | | |
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
-
+
-
-
+
+
-
+
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
keepAlive = false;
}
if (keepAlive) {
response.of_keepAlive = true;
_client->_stream = [stream retain];
_client->_lastURL = [URL copy];
_client->_lastURI = [URI copy];
_client->_lastWasHEAD =
(_request.method == OFHTTPRequestMethodHead);
_client->_lastResponse = [response retain];
}
if (_redirects > 0 && (_status == 301 || _status == 302 ||
_status == 303 || _status == 307) &&
(location = [_serverHeaders objectForKey: @"Location"]) != nil) {
bool follow = true;
OFURL *newURL;
OFString *newURLScheme;
OFURI *newURI;
OFString *newURIScheme;
newURL = [OFURL URLWithString: location
newURI = [OFURI URIWithString: location relativeToURI: URI];
relativeToURL: URL];
newURLScheme = newURL.scheme;
newURIScheme = newURI.scheme;
if ([newURLScheme caseInsensitiveCompare: @"http"] !=
if ([newURIScheme caseInsensitiveCompare: @"http"] !=
OFOrderedSame &&
[newURLScheme caseInsensitiveCompare: @"https"] !=
[newURIScheme caseInsensitiveCompare: @"https"] !=
OFOrderedSame)
follow = false;
if (!_client->_allowsInsecureRedirects &&
[URL.scheme caseInsensitiveCompare: @"https"] ==
[URI.scheme caseInsensitiveCompare: @"https"] ==
OFOrderedSame &&
[newURLScheme caseInsensitiveCompare: @"http"] ==
[newURIScheme caseInsensitiveCompare: @"http"] ==
OFOrderedSame)
follow = false;
if (follow && [_client->_delegate respondsToSelector: @selector(
client:shouldFollowRedirect:statusCode:request:response:)])
follow = [_client->_delegate client: _client
shouldFollowRedirect: newURL
shouldFollowRedirect: newURI
statusCode: _status
request: _request
response: response];
else if (follow)
follow = defaultShouldFollow(_request.method, _status);
if (follow) {
OFDictionary OF_GENERIC(OFString *, OFString *)
*headers = _request.headers;
OFHTTPRequest *newRequest =
[[_request copy] autorelease];
OFMutableDictionary *newHeaders =
[[headers mutableCopy] autorelease];
if (![newURL.host isEqual: URL.host])
if (![newURI.host isEqual: URI.host])
[newHeaders removeObjectForKey: @"Host"];
/*
* 303 means the request should be converted to a GET
* request before redirection. This also means stripping
* the entity of the request.
*/
|
︙ | | |
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
-
+
|
[key hasPrefix: @"Transfer-"])
[newHeaders
removeObjectForKey: key];
newRequest.method = OFHTTPRequestMethodGet;
}
newRequest.URL = newURL;
newRequest.URI = newURI;
newRequest.headers = newHeaders;
_client->_inProgress = false;
[_client asyncPerformRequest: newRequest
redirects: _redirects - 1];
return;
|
︙ | | |
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
|
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
|
-
+
-
+
-
+
|
if ([_client->_delegate respondsToSelector:
@selector(client:didCreateTCPSocket:request:)])
[_client->_delegate client: _client
didCreateTCPSocket: sock
request: _request];
if ([_request.URL.scheme caseInsensitiveCompare: @"https"] ==
if ([_request.URI.scheme caseInsensitiveCompare: @"https"] ==
OFOrderedSame) {
OFTLSStream *stream;
@try {
stream = [OFTLSStream streamWithStream: sock];
} @catch (OFNotImplementedException *e) {
[self raiseException:
[OFUnsupportedProtocolException
exceptionWithURL: _request.URL]];
exceptionWithURI: _request.URI]];
return;
}
if ([_client->_delegate respondsToSelector:
@selector(client:didCreateTLSStream:request:)])
[_client->_delegate client: _client
didCreateTLSStream: stream
request: _request];
stream.delegate = self;
[stream asyncPerformClientHandshakeWithHost: _request.URL.host];
[stream asyncPerformClientHandshakeWithHost: _request.URI.host];
} else {
sock.delegate = self;
[self performSelector: @selector(handleStream:)
withObject: sock
afterDelay: 0];
}
}
|
︙ | | |
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
|
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
|
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
|
[self performSelector: @selector(handleStream:)
withObject: stream
afterDelay: 0];
}
- (void)start
{
OFURL *URL = _request.URL;
OFURI *URI = _request.URI;
OFStream *stream;
/* Can we reuse the last socket? */
if (_client->_stream != nil && !_client->_stream.atEndOfStream &&
[_client->_lastURL.scheme isEqual: URL.scheme] &&
[_client->_lastURL.host isEqual: URL.host] &&
(_client->_lastURL.port == URL.port ||
[_client->_lastURL.port isEqual: URL.port]) &&
[_client->_lastURI.scheme isEqual: URI.scheme] &&
[_client->_lastURI.host isEqual: URI.host] &&
(_client->_lastURI.port == URI.port ||
[_client->_lastURI.port isEqual: URI.port]) &&
(_client->_lastWasHEAD || _client->_lastResponse.atEndOfStream)) {
/*
* Set _stream to nil, so that in case of an error it won't be
* reused. If everything is successful, we set _stream again
* at the end.
*/
stream = [_client->_stream autorelease];
_client->_stream = nil;
[_client->_lastURL release];
_client->_lastURL = nil;
[_client->_lastURI release];
_client->_lastURI = nil;
[_client->_lastResponse release];
_client->_lastResponse = nil;
stream.delegate = self;
[self performSelector: @selector(handleStream:)
withObject: stream
afterDelay: 0];
} else
[self closeAndReconnect];
}
- (void)closeAndReconnect
{
@try {
OFURL *URL = _request.URL;
OFURI *URI = _request.URI;
OFTCPSocket *sock;
uint16_t port;
OFNumber *URLPort;
OFNumber *URIPort;
[_client close];
sock = [OFTCPSocket socket];
if ([URL.scheme caseInsensitiveCompare: @"https"] ==
if ([URI.scheme caseInsensitiveCompare: @"https"] ==
OFOrderedSame)
port = 443;
else
port = 80;
URLPort = URL.port;
if (URLPort != nil)
port = URLPort.unsignedShortValue;
URIPort = URI.port;
if (URIPort != nil)
port = URIPort.unsignedShortValue;
sock.delegate = self;
[sock asyncConnectToHost: URL.host port: port];
[sock asyncConnectToHost: URI.host port: port];
} @catch (id e) {
[self raiseException: e];
}
}
@end
@implementation OFHTTPClientRequestBodyStream
|
︙ | | |
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
|
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
|
-
+
-
+
|
[_delegate client: client
didReceiveHeaders: headers
statusCode: statusCode
request: request];
}
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirect: (OFURL *)URL
shouldFollowRedirect: (OFURI *)URI
statusCode: (short)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
{
if ([_delegate respondsToSelector: @selector(client:
shouldFollowRedirect:statusCode:request:response:)])
return [_delegate client: client
shouldFollowRedirect: URL
shouldFollowRedirect: URI
statusCode: statusCode
request: request
response: response];
else
return defaultShouldFollow(request.method, statusCode);
}
@end
|
︙ | | |
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
|
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
|
-
-
+
+
-
+
-
-
+
+
|
[self asyncPerformRequest: request redirects: defaultRedirects];
}
- (void)asyncPerformRequest: (OFHTTPRequest *)request
redirects: (unsigned int)redirects
{
void *pool = objc_autoreleasePoolPush();
OFURL *URL = request.URL;
OFString *scheme = URL.scheme;
OFURI *URI = request.URI;
OFString *scheme = URI.scheme;
if ([scheme caseInsensitiveCompare: @"http"] != OFOrderedSame &&
[scheme caseInsensitiveCompare: @"https"] != OFOrderedSame)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if (_inProgress)
@throw [OFAlreadyConnectedException exception];
_inProgress = true;
[[[[OFHTTPClientRequestHandler alloc]
initWithClient: self
request: request
redirects: redirects] autorelease] start];
objc_autoreleasePoolPop(pool);
}
- (void)close
{
[_stream release];
_stream = nil;
[_lastURL release];
_lastURL = nil;
[_lastURI release];
_lastURI = nil;
[_lastResponse release];
_lastResponse = nil;
}
@end
|
Modified src/OFHTTPCookie.h
from [28d9caba77]
to [ff53970b1e].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFDate;
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFURL;
@class OFURI;
/**
* @class OFHTTPCookie OFHTTPCookie.h ObjFW/OFHTTPCookie.h
*
* @brief A class for storing and manipulating HTTP cookies.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
-
+
-
+
-
+
|
/**
* @brief An array of other attributes.
*/
@property (readonly, nonatomic)
OFMutableArray OF_GENERIC(OFString *) *extensions;
/**
* @brief Parses the specified response header fields for the specified URL and
* @brief Parses the specified response header fields for the specified URI and
* returns an array of cookies.
*
* @param headerFields The response header fields to parse
* @param URL The URL for the response header fields to parse
* @param URI The URI for the response header fields to parse
* @return An array of cookies
* @throw OFInvalidFormatException The specified response header has an invalid
* format
*/
+ (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields:
(OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields
forURL: (OFURL *)URL;
forURI: (OFURI *)URI;
/**
* @brief Returns the request header fields for the specified cookies.
*
* @param cookies The cookies to return the request header fields for
* @return The request header fields for the specified cookies
*/
|
︙ | | |
Modified src/OFHTTPCookie.m
from [0f6fbe0e26]
to [a7d6a07918].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
+
|
#include "config.h"
#import "OFHTTPCookie.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFInvalidFormatException.h"
static void
handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
{
OFString *lowercaseName = name.lowercaseString;
|
︙ | | |
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
+
-
+
|
@implementation OFHTTPCookie
@synthesize name = _name, value = _value, domain = _domain, path = _path;
@synthesize expires = _expires, secure = _secure, HTTPOnly = _HTTPOnly;
@synthesize extensions = _extensions;
+ (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields:
(OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields
forURL: (OFURL *)URL
forURI: (OFURI *)URI
{
OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
OFString *string = [headerFields objectForKey: @"Set-Cookie"];
OFString *domain = URL.host;
OFString *domain = URI.host;
const OFUnichar *characters = string.characters;
size_t length = string.length, last = 0;
enum {
statePreName,
stateName,
stateExpectValue,
stateValue,
|
︙ | | |
Modified src/OFHTTPCookieManager.h
from [776c67cc36]
to [3cc0432376].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
+
|
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFHTTPCookie;
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFURL;
@class OFURI;
/**
* @class OFHTTPCookieManager OFHTTPCookieManager.h ObjFW/OFHTTPCookieManager.h
*
* @brief A class for managing cookies for multiple domains.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
42
43
44
45
46
47
48
49
50
51
52
53
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
|
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
* @brief Create a new cookie manager.
*
* @return A new, autoreleased OFHTTPCookieManager
*/
+ (instancetype)manager;
/**
* @brief Adds the specified cookie for the specified URL.
* @brief Adds the specified cookie for the specified URI.
*
* @warning This modifies the cookie (e.g. it sets the domain if it is unset)!
* If you do not want this, pass a copy!
*
* @param cookie The cookie to add to the manager
* @param URL The URL for which the cookie should be added
* @param URI The URI for which the cookie should be added
*/
- (void)addCookie: (OFHTTPCookie *)cookie forURL: (OFURL *)URL;
- (void)addCookie: (OFHTTPCookie *)cookie forURI: (OFURI *)URI;
/**
* @brief Adds the specified cookies for the specified URL.
* @brief Adds the specified cookies for the specified URI.
*
* @warning This modifies the cookies (e.g. it sets the domain if it is unset)!
* If you do not want this, pass copies!
*
* @param cookies An array of cookies to add to the manager
* @param URL The URL for which the cookies should be added
* @param URI The URI for which the cookies should be added
*/
- (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
forURL: (OFURL *)URL;
forURI: (OFURI *)URI;
/**
* @brief Returns the cookies for the specified URL.
* @brief Returns the cookies for the specified URI.
*
* @param URL The URL for which the cookies should be returned
* @return The cookies for the specified URL
* @param URI The URI for which the cookies should be returned
* @return The cookies for the specified URI
*/
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURL: (OFURL *)URL;
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURI: (OFURI *)URI;
/**
* @brief Purges all expired cookies.
*/
- (void)purgeExpiredCookies;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFHTTPCookieManager.m
from [ab6e7fb16a]
to [1dd74fe07e].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
+
|
#include "config.h"
#import "OFHTTPCookieManager.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFHTTPCookie.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFHTTPCookieManager
+ (instancetype)manager
{
return [[[self alloc] init] autorelease];
}
|
︙ | | |
49
50
51
52
53
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
|
49
50
51
52
53
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
|
-
+
-
+
-
+
-
-
-
+
+
+
-
+
|
}
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
{
return [[_cookies copy] autorelease];
}
- (void)addCookie: (OFHTTPCookie *)cookie forURL: (OFURL *)URL
- (void)addCookie: (OFHTTPCookie *)cookie forURI: (OFURI *)URI
{
void *pool = objc_autoreleasePoolPush();
OFString *cookieDomain, *URLHost;
OFString *cookieDomain, *URIHost;
size_t i;
if (![cookie.path hasPrefix: @"/"])
cookie.path = @"/";
if (cookie.secure &&
[URL.scheme caseInsensitiveCompare: @"https"] != OFOrderedSame) {
[URI.scheme caseInsensitiveCompare: @"https"] != OFOrderedSame) {
objc_autoreleasePoolPop(pool);
return;
}
cookieDomain = cookie.domain.lowercaseString;
cookie.domain = cookieDomain;
URLHost = URL.host.lowercaseString;
if (![cookieDomain isEqual: URLHost]) {
URLHost = [@"." stringByAppendingString: URLHost];
URIHost = URI.host.lowercaseString;
if (![cookieDomain isEqual: URIHost]) {
URIHost = [@"." stringByAppendingString: URIHost];
if (![cookieDomain hasSuffix: URLHost]) {
if (![cookieDomain hasSuffix: URIHost]) {
objc_autoreleasePoolPop(pool);
return;
}
}
i = 0;
for (OFHTTPCookie *iter in _cookies) {
|
︙ | | |
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
[_cookies addObject: cookie];
objc_autoreleasePoolPop(pool);
}
- (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
forURL: (OFURL *)URL
forURI: (OFURI *)URI
{
for (OFHTTPCookie *cookie in cookies)
[self addCookie: cookie forURL: URL];
[self addCookie: cookie forURI: URI];
}
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURL: (OFURL *)URL
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURI: (OFURI *)URI
{
OFMutableArray *ret = [OFMutableArray array];
for (OFHTTPCookie *cookie in _cookies) {
void *pool;
OFDate *expires;
OFString *cookieDomain, *URLHost, *cookiePath, *URLPath;
OFString *cookieDomain, *URIHost, *cookiePath, *URIPath;
bool match;
expires = cookie.expires;
if (expires != nil && expires.timeIntervalSinceNow <= 0)
continue;
if (cookie.secure && [URL.scheme caseInsensitiveCompare:
if (cookie.secure && [URI.scheme caseInsensitiveCompare:
@"https"] != OFOrderedSame)
continue;
pool = objc_autoreleasePoolPush();
cookieDomain = cookie.domain.lowercaseString;
URLHost = URL.host.lowercaseString;
URIHost = URI.host.lowercaseString;
if ([cookieDomain hasPrefix: @"."]) {
if ([URLHost hasSuffix: cookieDomain])
if ([URIHost hasSuffix: cookieDomain])
match = true;
else {
cookieDomain =
[cookieDomain substringFromIndex: 1];
match = [cookieDomain isEqual: URLHost];
match = [cookieDomain isEqual: URIHost];
}
} else
match = [cookieDomain isEqual: URLHost];
match = [cookieDomain isEqual: URIHost];
if (!match) {
objc_autoreleasePoolPop(pool);
continue;
}
cookiePath = cookie.path;
URLPath = URL.path;
URIPath = URI.path;
if (![cookiePath isEqual: @"/"]) {
if ([cookiePath isEqual: URLPath])
if ([cookiePath isEqual: URIPath])
match = true;
else {
if (![cookiePath hasSuffix: @"/"])
cookiePath = [cookiePath
stringByAppendingString: @"/"];
match = [URLPath hasPrefix: cookiePath];
match = [URIPath hasPrefix: cookiePath];
}
if (!match) {
objc_autoreleasePoolPop(pool);
continue;
}
}
|
︙ | | |
Modified src/OFHTTPRequest.h
from [c73f1b3904]
to [1278addd47].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
+
|
#import "OFObject.h"
#import "OFSocket.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFData;
@class OFString;
/** @file */
/**
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
* @class OFHTTPRequest OFHTTPRequest.h ObjFW/OFHTTPRequest.h
*
* @brief A class for storing HTTP requests.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFHTTPRequest: OFObject <OFCopying>
{
OFURL *_URL;
OFURI *_URI;
OFHTTPRequestMethod _method;
OFHTTPRequestProtocolVersion _protocolVersion;
OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers;
OFSocketAddress _remoteAddress;
bool _hasRemoteAddress;
}
/**
* @brief The URL of the HTTP request.
* @brief The URI of the HTTP request.
*/
@property (copy, nonatomic) OFURL *URL;
@property (copy, nonatomic) OFURI *URI;
/**
* @brief The protocol version of the HTTP request.
*
* @throw OFUnsupportedVersionException The specified version cannot be set
* because it is not supported
*/
|
︙ | | |
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
-
+
-
+
-
+
-
+
-
+
-
+
|
* @brief The remote address from which the request originates.
*
* @note The setter creates a copy of the remote address.
*/
@property OF_NULLABLE_PROPERTY (nonatomic) const OFSocketAddress *remoteAddress;
/**
* @brief Creates a new OFHTTPRequest with the specified URL.
* @brief Creates a new OFHTTPRequest with the specified URI.
*
* @param URL The URL for the request
* @param URI The URI for the request
* @return A new, autoreleased OFHTTPRequest
*/
+ (instancetype)requestWithURL: (OFURL *)URL;
+ (instancetype)requestWithURI: (OFURI *)URI;
/**
* @brief Initializes an already allocated OFHTTPRequest with the specified URL.
* @brief Initializes an already allocated OFHTTPRequest with the specified URI.
*
* @param URL The URL for the request
* @param URI The URI for the request
* @return An initialized OFHTTPRequest
*/
- (instancetype)initWithURL: (OFURL *)URL;
- (instancetype)initWithURI: (OFURI *)URI;
- (instancetype)init OF_UNAVAILABLE;
@end
#ifdef __cplusplus
extern "C" {
#endif
|
︙ | | |
Modified src/OFHTTPRequest.m
from [faac6100ad]
to [c85955ea02].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
+
|
#include "config.h"
#include <string.h>
#import "OFHTTPRequest.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFDictionary.h"
#import "OFData.h"
#import "OFArray.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
|
︙ | | |
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
if ([string isEqual: @"CONNECT"])
return OFHTTPRequestMethodConnect;
@throw [OFInvalidFormatException exception];
}
@implementation OFHTTPRequest
@synthesize URL = _URL, method = _method, headers = _headers;
@synthesize URI = _URI, method = _method, headers = _headers;
+ (instancetype)requestWithURL: (OFURL *)URL
+ (instancetype)requestWithURI: (OFURI *)URI
{
return [[[self alloc] initWithURL: URL] autorelease];
return [[[self alloc] initWithURI: URI] autorelease];
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
{
self = [super init];
@try {
_URL = [URL copy];
_URI = [URI copy];
_method = OFHTTPRequestMethodGet;
_protocolVersion.major = 1;
_protocolVersion.minor = 1;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_URL release];
[_URI release];
[_headers release];
[super dealloc];
}
- (void)setRemoteAddress: (const OFSocketAddress *)remoteAddress
{
|
︙ | | |
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
-
+
|
return &_remoteAddress;
return NULL;
}
- (id)copy
{
OFHTTPRequest *copy = [[OFHTTPRequest alloc] initWithURL: _URL];
OFHTTPRequest *copy = [[OFHTTPRequest alloc] initWithURI: _URI];
@try {
copy->_method = _method;
copy->_protocolVersion = _protocolVersion;
copy.headers = _headers;
copy.remoteAddress = self.remoteAddress;
} @catch (id e) {
|
︙ | | |
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-
+
-
+
|
return false;
request = object;
if (request->_method != _method ||
request->_protocolVersion.major != _protocolVersion.major ||
request->_protocolVersion.minor != _protocolVersion.minor ||
![request->_URL isEqual: _URL] ||
![request->_URI isEqual: _URI] ||
![request->_headers isEqual: _headers])
return false;
if (request.remoteAddress != self.remoteAddress &&
!OFSocketAddressEqual(request.remoteAddress, self.remoteAddress))
return false;
return true;
}
- (unsigned long)hash
{
unsigned long hash;
OFHashInit(&hash);
OFHashAddByte(&hash, _method);
OFHashAddByte(&hash, _protocolVersion.major);
OFHashAddByte(&hash, _protocolVersion.minor);
OFHashAddHash(&hash, _URL.hash);
OFHashAddHash(&hash, _URI.hash);
OFHashAddHash(&hash, _headers.hash);
if (_hasRemoteAddress)
OFHashAddHash(&hash, OFSocketAddressHash(&_remoteAddress));
OFHashFinalize(&hash);
return hash;
|
︙ | | |
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
-
+
-
+
|
if (_hasRemoteAddress)
remoteAddress = OFSocketAddressString(&_remoteAddress);
else
remoteAddress = nil;
ret = [[OFString alloc] initWithFormat:
@"<%@:\n\tURL = %@\n"
@"<%@:\n\tURI = %@\n"
@"\tMethod = %s\n"
@"\tHeaders = %@\n"
@"\tRemote address = %@\n"
@">",
self.class, _URL, method, indentedHeaders, remoteAddress];
self.class, _URI, method, indentedHeaders, remoteAddress];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
@end
|
Modified src/OFHTTPServer.m
from [aa1c799693]
to [684e137d81].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
|
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFNumber.h"
#import "OFSocket+Private.h"
#import "OFTCPSocket.h"
#import "OFThread.h"
#import "OFTimer.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFAlreadyConnectedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
#import "OFOutOfMemoryException.h"
|
︙ | | |
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
|
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
|
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
+
-
+
|
date, _server.name];
return false;
}
- (void)createResponse
{
void *pool = objc_autoreleasePoolPush();
OFMutableURL *URL;
OFMutableURI *URI;
OFHTTPRequest *request;
OFHTTPServerResponse *response;
size_t pos;
[_timer invalidate];
[_timer release];
_timer = nil;
if (_host == nil || _port == 0) {
if (_HTTPMinorVersion > 0) {
[self sendErrorAndClose: 400];
return;
}
[_host release];
_host = [_server.host copy];
_port = [_server port];
}
URL = [OFMutableURL URL];
URL.scheme = @"http";
URL.host = _host;
URI = [OFMutableURI URI];
URI.scheme = @"http";
URI.host = _host;
if (_port != 80)
URL.port = [OFNumber numberWithUnsignedShort: _port];
URI.port = [OFNumber numberWithUnsignedShort: _port];
@try {
if ((pos = [_path rangeOfString: @"?"].location) !=
OFNotFound) {
OFString *path, *query;
path = [_path substringToIndex: pos];
query = [_path substringFromIndex: pos + 1];
URL.URLEncodedPath = path;
URL.URLEncodedQuery = query;
URI.percentEncodedPath = path;
URI.percentEncodedQuery = query;
} else
URL.URLEncodedPath = _path;
URI.percentEncodedPath = _path;
} @catch (OFInvalidFormatException *e) {
objc_autoreleasePoolPop(pool);
[self sendErrorAndClose: 400];
return;
}
[URL makeImmutable];
[URI makeImmutable];
request = [OFHTTPRequest requestWithURL: URL];
request = [OFHTTPRequest requestWithURI: URI];
request.method = _method;
request.protocolVersion =
(OFHTTPRequestProtocolVersion){ 1, _HTTPMinorVersion };
request.headers = _headers;
request.remoteAddress = _socket.remoteAddress;
response = [[[OFHTTPServerResponse alloc]
|
︙ | | |
Renamed and modified
src/OFHTTPURLHandler.h
[6b4755acdc]
to src/OFHTTPURIHandler.h
[1fbd933246].
︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
-
+
-
+
|
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURLHandler.h"
#import "OFURIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFHTTPURLHandler: OFURLHandler
@interface OFHTTPURIHandler: OFURIHandler
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFHTTPURLHandler.m
[26da6a20ea]
to src/OFHTTPURIHandler.m
[9e6fa9d3fe].
︙ | | |
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
-
+
-
-
+
+
-
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFHTTPURLHandler.h"
#import "OFHTTPURIHandler.h"
#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
@implementation OFHTTPURLHandler
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
@implementation OFHTTPURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFHTTPClient *client = [OFHTTPClient client];
OFHTTPRequest *request = [OFHTTPRequest requestWithURL: URL];
OFHTTPRequest *request = [OFHTTPRequest requestWithURI: URI];
OFHTTPResponse *response = [client performRequest: request];
[response retain];
objc_autoreleasePoolPop(pool);
return [response autorelease];
}
@end
|
Modified src/OFINIFile.h
from [7ac69fbcc1]
to [f35fd21473].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFObject.h"
#import "OFString.h"
#import "OFINICategory.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFURL;
@class OFURI;
/**
* @class OFINIFile OFINIFile.h ObjFW/OFINIFile.h
*
* @brief A class for reading, creating and modifying INI files.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFINIFile: OFObject
{
OFMutableArray OF_GENERIC(OFINICategory *) *_categories;
}
/**
* @brief All categories in the INI file.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(OFINICategory *) *categories;
/**
* @brief Creates a new OFINIFile with the contents of the specified file.
*
* @param URL The URL to the file whose contents the OFINIFile should contain
* @param URI The URI to the file whose contents the OFINIFile should contain
*
* @return A new, autoreleased OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
+ (instancetype)fileWithURL: (OFURL *)URL;
+ (instancetype)fileWithURI: (OFURI *)URI;
/**
* @brief Creates a new OFINIFile with the contents of the specified file in
* the specified encoding.
*
* @param URL The URL to the file whose contents the OFINIFile should contain
* @param URI The URI to the file whose contents the OFINIFile should contain
* @param encoding The encoding of the specified file
* @return A new, autoreleased OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
+ (instancetype)fileWithURL: (OFURL *)URL encoding: (OFStringEncoding)encoding;
+ (instancetype)fileWithURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFINIFile with the contents of the
* specified file.
*
* @param URL The URL to the file whose contents the OFINIFile should contain
* @param URI The URI to the file whose contents the OFINIFile should contain
*
* @return An initialized OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
- (instancetype)initWithURL: (OFURL *)URL;
- (instancetype)initWithURI: (OFURI *)URI;
/**
* @brief Initializes an already allocated OFINIFile with the contents of the
* specified file in the specified encoding.
*
* @param URL The URL to the file whose contents the OFINIFile should contain
* @param URI The URI to the file whose contents the OFINIFile should contain
* @param encoding The encoding of the specified file
* @return An initialized OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
encoding: (OFStringEncoding)encoding
OF_DESIGNATED_INITIALIZER;
/**
* @brief Returns an @ref OFINICategory for the category with the specified
* name.
*
* @param name The name of the category for which an @ref OFINICategory should
* be returned
*
* @return An @ref OFINICategory for the category with the specified name
*/
- (OFINICategory *)categoryForName: (OFString *)name;
/**
* @brief Writes the contents of the OFINIFile to a file.
*
* @param URL The URL of the file to write to
* @param URI The URI of the file to write to
*/
- (void)writeToURL: (OFURL *)URL;
- (void)writeToURI: (OFURI *)URI;
/**
* @brief Writes the contents of the OFINIFile to a file in the specified
* encoding.
*
* @param URL The URL of the file to write to
* @param URI The URI of the file to write to
* @param encoding The encoding to use
*/
- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding;
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFINIFile.m
from [8c3437c559]
to [7850530cf1].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFINIFile.h"
#import "OFArray.h"
#import "OFINICategory+Private.h"
#import "OFINICategory.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURLHandler.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFInvalidFormatException.h"
#import "OFOpenItemFailedException.h"
OF_DIRECT_MEMBERS
@interface OFINIFile ()
- (void)of_parseURL: (OFURL *)URL encoding: (OFStringEncoding)encoding;
- (void)of_parseURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
@end
static bool
isWhitespaceLine(OFString *line)
{
const char *cString = line.UTF8String;
size_t length = line.UTF8StringLength;
for (size_t i = 0; i < length; i++)
if (!OFASCIIIsSpace(cString[i]))
return false;
return true;
}
@implementation OFINIFile
@synthesize categories = _categories;
+ (instancetype)fileWithURL: (OFURL *)URL
+ (instancetype)fileWithURI: (OFURI *)URI
{
return [[[self alloc] initWithURL: URL] autorelease];
return [[[self alloc] initWithURI: URI] autorelease];
}
+ (instancetype)fileWithURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
+ (instancetype)fileWithURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
{
return [[[self alloc] initWithURL: URL encoding: encoding] autorelease];
return [[[self alloc] initWithURI: URI encoding: encoding] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
{
return [self initWithURL: URL encoding: OFStringEncodingAutodetect];
return [self initWithURI: URI encoding: OFStringEncodingAutodetect];
}
- (instancetype)initWithURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
- (instancetype)initWithURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
{
self = [super init];
@try {
_categories = [[OFMutableArray alloc] init];
[self of_parseURL: URL encoding: encoding];
[self of_parseURI: URI encoding: encoding];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
︙ | | |
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
131
|
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
131
|
-
+
-
+
|
[_categories addObject: category];
objc_autoreleasePoolPop(pool);
return category;
}
- (void)of_parseURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
- (void)of_parseURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
{
void *pool = objc_autoreleasePoolPush();
OFStream *file;
OFINICategory *category = nil;
OFString *line;
if (encoding == OFStringEncodingAutodetect)
encoding = OFStringEncodingUTF8;
@try {
file = [OFURLHandler openItemAtURL: URL mode: @"r"];
file = [OFURIHandler openItemAtURI: URI mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
/* Handle missing file like an empty file */
if (e.errNo == ENOENT)
return;
@throw e;
}
|
︙ | | |
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
-
+
-
+
-
+
-
+
|
[category of_parseLine: line];
}
}
objc_autoreleasePoolPop(pool);
}
- (void)writeToURL: (OFURL *)URL
- (void)writeToURI: (OFURI *)URI
{
[self writeToURL: URL encoding: OFStringEncodingUTF8];
[self writeToURI: URI encoding: OFStringEncodingUTF8];
}
- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
{
void *pool = objc_autoreleasePoolPush();
OFStream *file = [OFURLHandler openItemAtURL: URL mode: @"w"];
OFStream *file = [OFURIHandler openItemAtURI: URI mode: @"w"];
bool first = true;
for (OFINICategory *category in _categories)
if ([category of_writeToStream: file
encoding: encoding
first: first])
first = false;
|
︙ | | |
Modified src/OFINIFileSettings.h
from [e6622a40c7]
to [125e92a3e8].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
+
-
+
|
#import "OFSettings.h"
OF_ASSUME_NONNULL_BEGIN
@class OFINIFile;
@class OFString;
@class OFURL;
@class OFURI;
@interface OFINIFileSettings: OFSettings
{
OFURL *_fileURL;
OFURI *_fileURI;
OFINIFile *_INIFile;
}
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFINIFileSettings.m
from [06a12ac82c]
to [b3d1a39e2b].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
+
-
-
-
+
+
+
-
+
|
#include "config.h"
#import "OFINIFileSettings.h"
#import "OFArray.h"
#import "OFINIFile.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFINIFileSettings
- (instancetype)initWithApplicationName: (OFString *)applicationName
{
self = [super initWithApplicationName: applicationName];
@try {
void *pool = objc_autoreleasePoolPush();
OFString *fileName;
fileName = [applicationName stringByAppendingString: @".ini"];
_fileURL = [[[OFSystemInfo userConfigURL]
URLByAppendingPathComponent: fileName] copy];
_INIFile = [[OFINIFile alloc] initWithURL: _fileURL];
_fileURI = [[[OFSystemInfo userConfigURI]
URIByAppendingPathComponent: fileName] copy];
_INIFile = [[OFINIFile alloc] initWithURI: _fileURI];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_fileURL release];
[_fileURI release];
[_INIFile release];
[super dealloc];
}
- (void)of_getCategory: (OFString **)category
andKey: (OFString **)key
|
︙ | | |
239
240
241
242
243
244
245
246
247
248
|
239
240
241
242
243
244
245
246
247
248
|
-
+
|
[[_INIFile categoryForName: category] removeValueForKey: key];
objc_autoreleasePoolPop(pool);
}
- (void)save
{
[_INIFile writeToURL: _fileURL];
[_INIFile writeToURI: _fileURI];
}
@end
|
Modified src/OFLHAArchive.h
from [e45df52e7c]
to [64d7bcc38b].
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
+
|
#import "OFKernelEventObserver.h"
#import "OFLHAArchiveEntry.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFStream;
@class OFURL;
@class OFURI;
/**
* @class OFLHAArchive OFLHAArchive.h ObjFW/OFLHAArchive.h
*
* @brief A class for accessing and manipulating LHA files.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
-
+
-
+
|
* @return A new, autoreleased OFLHAArchive
*/
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
/**
* @brief Creates a new OFLHAArchive object with the specified file.
*
* @param URL The URL to the LHA file
* @param URI The URI to the LHA file
* @param mode The mode for the LHA file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return A new, autoreleased OFLHAArchive
*/
+ (instancetype)archiveWithURL: (OFURL *)URL mode: (OFString *)mode;
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFLHAArchive object with the
* specified stream.
*
|
︙ | | |
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
-
+
-
+
|
- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated OFLHAArchive object with the
* specified file.
*
* @param URL The URL to the LHA file
* @param URI The URI to the LHA file
* @param mode The mode for the LHA file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return An initialized OFLHAArchive
*/
- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode;
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode;
/**
* @brief Returns the next entry from the LHA archive or `nil` if all entries
* have been read.
*
* @note This is only available in read mode.
*
|
︙ | | |
Modified src/OFLHAArchive.m
from [42c3ad0bd8]
to [37612138b5].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
-
+
|
#import "OFLHAArchiveEntry.h"
#import "OFLHAArchiveEntry+Private.h"
#import "OFCRC16.h"
#import "OFLHADecompressingStream.h"
#import "OFSeekableStream.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFURLHandler.h"
#import "OFURIHandler.h"
#import "OFChecksumMismatchException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
|
︙ | | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
-
+
-
+
|
@synthesize encoding = _encoding;
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
}
+ (instancetype)archiveWithURL: (OFURL *)URL mode: (OFString *)mode
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode
{
return [[[self alloc] initWithURL: URL mode: mode] autorelease];
return [[[self alloc] initWithURI: URI mode: mode] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
-
+
-
+
-
+
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFStream *stream;
@try {
if ([mode isEqual: @"a"])
stream = [OFURLHandler openItemAtURL: URL mode: @"r+"];
stream = [OFURIHandler openItemAtURI: URI mode: @"r+"];
else
stream = [OFURLHandler openItemAtURL: URL mode: mode];
stream = [OFURIHandler openItemAtURI: URI mode: mode];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStream: stream mode: mode];
|
︙ | | |
Modified src/OFMutableData.h
from [5eba71457e]
to [23548715da].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
+
|
*/
#import "OFData.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFURL;
@class OFURI;
/**
* @class OFMutableData OFMutableData.h ObjFW/OFMutableData.h
*
* @brief A class for storing and manipulating arbitrary data in an array.
*/
@interface OFMutableData: OFData
|
︙ | | |
200
201
202
203
204
205
206
207
208
209
210
211
212
|
200
201
202
203
204
205
206
207
208
209
210
211
212
|
-
+
|
/**
* @brief Removes all items.
*/
- (void)removeAllItems;
/**
* @brief Converts the mutable URL to an immutable URL.
* @brief Converts the mutable data to an immutable data.
*/
- (void)makeImmutable;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFMutableString.m
from [b626e8ca80]
to [eb3bef8a08].
︙ | | |
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-
+
-
+
-
+
-
+
|
{
return (id)[[OFMutableUTF8String alloc]
initWithContentsOfFile: path
encoding: encoding];
}
#endif
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
{
return (id)[[OFMutableUTF8String alloc] initWithContentsOfURL: URL];
return (id)[[OFMutableUTF8String alloc] initWithContentsOfURI: URI];
}
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
encoding: (OFStringEncoding)encoding
{
return (id)[[OFMutableUTF8String alloc]
initWithContentsOfURL: URL
initWithContentsOfURI: URI
encoding: encoding];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMutableUTF8String alloc] initWithSerialization: element];
}
|
︙ | | |
Renamed and modified
src/OFMutableURL.h
[7d66205ed8]
to src/OFMutableURI.h
[c337456a13].
︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
|
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURL.h"
#import "OFURI.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFMutableURL OFMutableURL.h ObjFW/OFMutableURL.h
* @class OFMutableURI OFMutableURI.h ObjFW/OFMutableURI.h
*
* @brief A class for parsing URLs and accessing parts of it.
* @brief A class for parsing URIs and accessing parts of it.
*/
@interface OFMutableURL: OFURL
@interface OFMutableURI: OFURI
{
OF_RESERVE_IVARS(OFMutableURL, 4)
OF_RESERVE_IVARS(OFMutableURI, 4)
}
/**
* @brief The scheme part of the URL.
* @brief The scheme part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *scheme;
/**
* @brief The scheme part of the URL in URL-encoded form.
* @brief The scheme part of the URI in percent-encoded form.
*
* Setting this retains the original URL-encoding used - if more characters
* than necessary are URL-encoded, it is kept this way.
* Setting this retains the original percent-encoding used - if more characters
* than necessary are percent-encoded, it is kept this way.
*
* @throw OFInvalidFormatException The scheme being set is not in the correct
* format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFString *URLEncodedScheme;
OFString *percentEncodedScheme;
/**
* @brief The host part of the URL.
* @brief The host part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *host;
/**
* @brief The host part of the URL in URL-encoded form.
* @brief The host part of the URI in percent-encoded form.
*
* Setting this retains the original URL-encoding used - if more characters
* than necessary are URL-encoded, it is kept this way.
* Setting this retains the original percent-encoding used - if more characters
* than necessary are percent-encoded, it is kept this way.
*
* @throw OFInvalidFormatException The host being set is not in the correct
* format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFString *URLEncodedHost;
OFString *percentEncodedHost;
/**
* @brief The port part of the URL.
* @brief The port part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFNumber *port;
/**
* @brief The user part of the URL.
* @brief The user part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *user;
/**
* @brief The user part of the URL in URL-encoded form.
* @brief The user part of the URI in percent-encoded form.
*
* Setting this retains the original URL-encoding used - if more characters
* than necessary are URL-encoded, it is kept this way.
* Setting this retains the original percent-encoding used - if more characters
* than necessary are percent-encoded, it is kept this way.
*
* @throw OFInvalidFormatException The user being set is not in the correct
* format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFString *URLEncodedUser;
OFString *percentEncodedUser;
/**
* @brief The password part of the URL.
* @brief The password part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *password;
/**
* @brief The password part of the URL in URL-encoded form.
* @brief The password part of the URI in URI-encoded form.
*
* Setting this retains the original URL-encoding used - if more characters
* than necessary are URL-encoded, it is kept this way.
* Setting this retains the original percent-encoding used - if more characters
* than necessary are percent-encoded, it is kept this way.
*
* @throw OFInvalidFormatException The password being set is not in the correct
* format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFString *URLEncodedPassword;
OFString *percentEncodedPassword;
/**
* @brief The path part of the URL.
* @brief The path part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *path;
/**
* @brief The path part of the URL in URL-encoded form.
* @brief The path part of the URI in percent-encoded form.
*
* Setting this retains the original URL-encoding used - if more characters
* than necessary are URL-encoded, it is kept this way.
* Setting this retains the original percent-encoding used - if more characters
* than necessary are percent-encoded, it is kept this way.
*
* @throw OFInvalidFormatException The path being set is not in the correct
* format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFString *URLEncodedPath;
OFString *percentEncodedPath;
/**
* @brief The path of the URL split into components.
* @brief The path of the URI split into components.
*
* The first component must always be empty to designate the root.
*
* @throw OFInvalidFormatException The path components being set are not in the
* correct format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFArray OF_GENERIC(OFString *) *pathComponents;
/**
* @brief The query part of the URL.
* @brief The query part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *query;
/**
* @brief The query part of the URL in URL-encoded form.
* @brief The query part of the URI in percent-encoded form.
*
* Setting this retains the original URL-encoding used - if more characters
* than necessary are URL-encoded, it is kept this way.
* Setting this retains the original percent-encoding used - if more characters
* than necessary are percent-encoded, it is kept this way.
*
* @throw OFInvalidFormatException The query being set is not in the correct
* format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFString *URLEncodedQuery;
OFString *percentEncodedQuery;
/**
* @brief The query part of the URL as a dictionary.
* @brief The query part of the URI as a dictionary.
*
* For example, a query like `key1=value1&key2=value2` would correspond to the
* following dictionary:
*
* @{
* @"key1": @"value1",
* @"key2": @"value2"
* }
*
* @throw OFInvalidFormatException The query is not in the correct format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFDictionary OF_GENERIC(OFString *, OFString *) *queryDictionary;
/**
* @brief The fragment part of the URL.
* @brief The fragment part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *fragment;
/**
* @brief The fragment part of the URL in URL-encoded form.
* @brief The fragment part of the URI in percent-encoded form.
*
* Setting this retains the original URL-encoding used - if more characters
* than necessary are URL-encoded, it is kept this way.
* Setting this retains the original percent-encoding used - if more characters
* than necessary are percent-encoded, it is kept this way.
*
* @throw OFInvalidFormatException The fragment being set is not in the correct
* format
*/
@property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic)
OFString *URLEncodedFragment;
OFString *percentEncodedFragment;
/**
* @brief Creates a new mutable URL.
* @brief Creates a new mutable URI.
*
* @return A new, autoreleased OFMutableURL
* @return A new, autoreleased OFMutableURI
*/
+ (instancetype)URL;
+ (instancetype)URI;
/**
* @brief Appends the specified path component.
*
* @param component The component to append
*/
- (void)appendPathComponent: (OFString *)component;
|
︙ | | |
204
205
206
207
208
209
210
211
212
213
214
215
216
|
204
205
206
207
208
209
210
211
212
213
214
215
216
|
-
+
|
/**
* @brief Resolves relative subpaths.
*/
- (void)standardizePath;
/**
* @brief Converts the mutable URL to an immutable URL.
* @brief Converts the mutable URI to an immutable URI.
*/
- (void)makeImmutable;
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFMutableURL.m
[079bad7720]
to src/OFMutableURI.m
[963a0a611c].
︙ | | |
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
+
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFMutableURL.h"
#import "OFMutableURI.h"
#import "OFArray.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFileManager.h"
#endif
#import "OFNumber.h"
#import "OFString.h"
#import "OFInvalidFormatException.h"
@implementation OFMutableURL
@dynamic scheme, URLEncodedScheme, host, URLEncodedHost, port, user;
@dynamic URLEncodedUser, password, URLEncodedPassword, path, URLEncodedPath;
@dynamic pathComponents, query, URLEncodedQuery, queryDictionary, fragment;
@dynamic URLEncodedFragment;
@implementation OFMutableURI
@dynamic scheme, percentEncodedScheme, host, percentEncodedHost, port, user;
@dynamic percentEncodedUser, password, percentEncodedPassword, path;
@dynamic percentEncodedPath, pathComponents, query, percentEncodedQuery;
@dynamic queryDictionary, fragment, percentEncodedFragment;
+ (instancetype)URL
+ (instancetype)URI
{
return [[[self alloc] init] autorelease];
}
- (void)setScheme: (OFString *)scheme
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _URLEncodedScheme;
OFString *old = _percentEncodedScheme;
_percentEncodedScheme = [[scheme
_URLEncodedScheme = [[scheme stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLSchemeAllowedCharacterSet]] copy];
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URISchemeAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setURLEncodedScheme: (OFString *)URLEncodedScheme
- (void)setPercentEncodedScheme: (OFString *)percentEncodedScheme
{
OFString *old;
if (URLEncodedScheme != nil)
OFURLVerifyIsEscaped(URLEncodedScheme,
[OFCharacterSet URLSchemeAllowedCharacterSet]);
if (percentEncodedScheme != nil)
OFURIVerifyIsEscaped(percentEncodedScheme,
[OFCharacterSet URISchemeAllowedCharacterSet]);
old = _URLEncodedScheme;
_URLEncodedScheme = [URLEncodedScheme copy];
old = _percentEncodedScheme;
_percentEncodedScheme = [percentEncodedScheme copy];
[old release];
}
- (void)setHost: (OFString *)host
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _URLEncodedHost;
OFString *old = _percentEncodedHost;
if (OFURLIsIPv6Host(host))
_URLEncodedHost = [[OFString alloc]
if (OFURIIsIPv6Host(host))
_percentEncodedHost = [[OFString alloc]
initWithFormat: @"[%@]", host];
else
_URLEncodedHost = [[host
stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLHostAllowedCharacterSet]] copy];
_percentEncodedHost = [[host
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIHostAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setURLEncodedHost: (OFString *)URLEncodedHost
- (void)setPercentEncodedHost: (OFString *)percentEncodedHost
{
OFString *old;
if ([URLEncodedHost hasPrefix: @"["] &&
[URLEncodedHost hasSuffix: @"]"]) {
if (!OFURLIsIPv6Host([URLEncodedHost substringWithRange:
OFMakeRange(1, URLEncodedHost.length - 2)]))
if ([percentEncodedHost hasPrefix: @"["] &&
[percentEncodedHost hasSuffix: @"]"]) {
if (!OFURIIsIPv6Host([percentEncodedHost substringWithRange:
OFMakeRange(1, percentEncodedHost.length - 2)]))
@throw [OFInvalidFormatException exception];
} else if (URLEncodedHost != nil)
OFURLVerifyIsEscaped(URLEncodedHost,
[OFCharacterSet URLHostAllowedCharacterSet]);
} else if (percentEncodedHost != nil)
OFURIVerifyIsEscaped(percentEncodedHost,
[OFCharacterSet URIHostAllowedCharacterSet]);
old = _URLEncodedHost;
_URLEncodedHost = [URLEncodedHost copy];
old = _percentEncodedHost;
_percentEncodedHost = [percentEncodedHost copy];
[old release];
}
- (void)setPort: (OFNumber *)port
{
OFNumber *old = _port;
_port = [port copy];
[old release];
}
- (void)setUser: (OFString *)user
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _URLEncodedUser;
OFString *old = _percentEncodedUser;
_percentEncodedUser = [[user
_URLEncodedUser = [[user stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLUserAllowedCharacterSet]] copy];
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIUserAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setURLEncodedUser: (OFString *)URLEncodedUser
- (void)setPercentEncodedUser: (OFString *)percentEncodedUser
{
OFString *old;
if (URLEncodedUser != nil)
OFURLVerifyIsEscaped(URLEncodedUser,
[OFCharacterSet URLUserAllowedCharacterSet]);
if (percentEncodedUser != nil)
OFURIVerifyIsEscaped(percentEncodedUser,
[OFCharacterSet URIUserAllowedCharacterSet]);
old = _URLEncodedUser;
_URLEncodedUser = [URLEncodedUser copy];
old = _percentEncodedUser;
_percentEncodedUser = [percentEncodedUser copy];
[old release];
}
- (void)setPassword: (OFString *)password
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _URLEncodedPassword;
OFString *old = _percentEncodedPassword;
_URLEncodedPassword = [[password
stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLPasswordAllowedCharacterSet]] copy];
_percentEncodedPassword = [[password
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIPasswordAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setURLEncodedPassword: (OFString *)URLEncodedPassword
- (void)setPercentEncodedPassword: (OFString *)percentEncodedPassword
{
OFString *old;
if (URLEncodedPassword != nil)
OFURLVerifyIsEscaped(URLEncodedPassword,
[OFCharacterSet URLPasswordAllowedCharacterSet]);
if (percentEncodedPassword != nil)
OFURIVerifyIsEscaped(percentEncodedPassword,
[OFCharacterSet URIPasswordAllowedCharacterSet]);
old = _URLEncodedPassword;
_URLEncodedPassword = [URLEncodedPassword copy];
old = _percentEncodedPassword;
_percentEncodedPassword = [percentEncodedPassword copy];
[old release];
}
- (void)setPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _URLEncodedPath;
OFString *old = _percentEncodedPath;
_percentEncodedPath = [[path
_URLEncodedPath = [[path stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLPathAllowedCharacterSet]] copy];
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIPathAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setURLEncodedPath: (OFString *)URLEncodedPath
- (void)setPercentEncodedPath: (OFString *)percentEncodedPath
{
OFString *old;
if (URLEncodedPath != nil)
OFURLVerifyIsEscaped(URLEncodedPath,
[OFCharacterSet URLPathAllowedCharacterSet]);
if (percentEncodedPath != nil)
OFURIVerifyIsEscaped(percentEncodedPath,
[OFCharacterSet URIPathAllowedCharacterSet]);
old = _URLEncodedPath;
_URLEncodedPath = [URLEncodedPath copy];
old = _percentEncodedPath;
_percentEncodedPath = [percentEncodedPath copy];
[old release];
}
- (void)setPathComponents: (OFArray *)components
{
void *pool = objc_autoreleasePoolPush();
|
︙ | | |
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
|
objc_autoreleasePoolPop(pool);
}
- (void)setQuery: (OFString *)query
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _URLEncodedQuery;
OFString *old = _percentEncodedQuery;
_percentEncodedQuery = [[query
_URLEncodedQuery = [[query stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLQueryAllowedCharacterSet]] copy];
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIQueryAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setURLEncodedQuery: (OFString *)URLEncodedQuery
- (void)setPercentEncodedQuery: (OFString *)percentEncodedQuery
{
OFString *old;
if (URLEncodedQuery != nil)
OFURLVerifyIsEscaped(URLEncodedQuery,
[OFCharacterSet URLQueryAllowedCharacterSet]);
if (percentEncodedQuery != nil)
OFURIVerifyIsEscaped(percentEncodedQuery,
[OFCharacterSet URIQueryAllowedCharacterSet]);
old = _URLEncodedQuery;
_URLEncodedQuery = [URLEncodedQuery copy];
old = _percentEncodedQuery;
_percentEncodedQuery = [percentEncodedQuery copy];
[old release];
}
- (void)setQueryDictionary:
(OFDictionary OF_GENERIC(OFString *, OFString *) *)dictionary
{
void *pool;
OFMutableString *URLEncodedQuery;
OFMutableString *percentEncodedQuery;
OFEnumerator OF_GENERIC(OFString *) *keyEnumerator, *objectEnumerator;
OFCharacterSet *characterSet;
OFString *key, *object, *old;
if (dictionary == nil) {
[_URLEncodedQuery release];
_URLEncodedQuery = nil;
[_percentEncodedQuery release];
_percentEncodedQuery = nil;
return;
}
pool = objc_autoreleasePoolPush();
URLEncodedQuery = [OFMutableString string];
percentEncodedQuery = [OFMutableString string];
keyEnumerator = [dictionary keyEnumerator];
objectEnumerator = [dictionary objectEnumerator];
characterSet = [OFCharacterSet URLQueryKeyValueAllowedCharacterSet];
characterSet = [OFCharacterSet URIQueryKeyValueAllowedCharacterSet];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
key = [key
stringByURLEncodingWithAllowedCharacters: characterSet];
key = [key stringByAddingPercentEncodingWithAllowedCharacters:
characterSet];
object = [object
stringByURLEncodingWithAllowedCharacters: characterSet];
stringByAddingPercentEncodingWithAllowedCharacters:
characterSet];
if (URLEncodedQuery.length > 0)
[URLEncodedQuery appendString: @"&"];
if (percentEncodedQuery.length > 0)
[percentEncodedQuery appendString: @"&"];
[URLEncodedQuery appendFormat: @"%@=%@", key, object];
[percentEncodedQuery appendFormat: @"%@=%@", key, object];
}
old = _URLEncodedQuery;
_URLEncodedQuery = [URLEncodedQuery copy];
old = _percentEncodedQuery;
_percentEncodedQuery = [percentEncodedQuery copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setFragment: (OFString *)fragment
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _URLEncodedFragment;
OFString *old = _percentEncodedFragment;
_URLEncodedFragment = [[fragment
stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLFragmentAllowedCharacterSet]] copy];
_percentEncodedFragment = [[fragment
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIFragmentAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setURLEncodedFragment: (OFString *)URLEncodedFragment
- (void)setPercentEncodedFragment: (OFString *)percentEncodedFragment
{
OFString *old;
if (URLEncodedFragment != nil)
OFURLVerifyIsEscaped(URLEncodedFragment,
[OFCharacterSet URLFragmentAllowedCharacterSet]);
if (percentEncodedFragment != nil)
OFURIVerifyIsEscaped(percentEncodedFragment,
[OFCharacterSet URIFragmentAllowedCharacterSet]);
old = _URLEncodedFragment;
_URLEncodedFragment = [URLEncodedFragment copy];
old = _percentEncodedFragment;
_percentEncodedFragment = [percentEncodedFragment copy];
[old release];
}
- (id)copy
{
OFMutableURL *copy = [self mutableCopy];
OFMutableURI *copy = [self mutableCopy];
[copy makeImmutable];
return copy;
}
- (void)appendPathComponent: (OFString *)component
{
[self appendPathComponent: component isDirectory: false];
#ifdef OF_HAVE_FILES
if ([_URLEncodedScheme isEqual: @"file"] &&
![_URLEncodedPath hasSuffix: @"/"] &&
[[OFFileManager defaultManager] directoryExistsAtURL: self]) {
if ([_percentEncodedScheme isEqual: @"file"] &&
![_percentEncodedPath hasSuffix: @"/"] &&
[[OFFileManager defaultManager] directoryExistsAtURI: self]) {
void *pool = objc_autoreleasePoolPush();
OFString *path = [_URLEncodedPath
OFString *path = [_percentEncodedPath
stringByAppendingString: @"/"];
[_URLEncodedPath release];
_URLEncodedPath = [path retain];
[_percentEncodedPath release];
_percentEncodedPath = [path retain];
objc_autoreleasePoolPop(pool);
}
#endif
}
- (void)appendPathComponent: (OFString *)component
isDirectory: (bool)isDirectory
{
void *pool;
OFString *path;
if ([component isEqual: @"/"] && [_URLEncodedPath hasSuffix: @"/"])
if ([component isEqual: @"/"] && [_percentEncodedPath hasSuffix: @"/"])
return;
pool = objc_autoreleasePoolPush();
component = [component stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLPathAllowedCharacterSet]];
component = [component
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIPathAllowedCharacterSet]];
#if defined(OF_WINDOWS) || defined(OF_MSDOS)
if ([_URLEncodedPath hasSuffix: @"/"] ||
([_URLEncodedScheme isEqual: @"file"] &&
[_URLEncodedPath hasSuffix: @":"]))
if ([_percentEncodedPath hasSuffix: @"/"] ||
([_percentEncodedScheme isEqual: @"file"] &&
[_percentEncodedPath hasSuffix: @":"]))
#else
if ([_URLEncodedPath hasSuffix: @"/"])
if ([_percentEncodedPath hasSuffix: @"/"])
#endif
path = [_URLEncodedPath stringByAppendingString: component];
path = [_percentEncodedPath stringByAppendingString: component];
else
path = [_URLEncodedPath
path = [_percentEncodedPath
stringByAppendingFormat: @"/%@", component];
if (isDirectory && ![path hasSuffix: @"/"])
path = [path stringByAppendingString: @"/"];
[_URLEncodedPath release];
_URLEncodedPath = [path retain];
[_percentEncodedPath release];
_percentEncodedPath = [path retain];
objc_autoreleasePoolPop(pool);
}
- (void)standardizePath
{
void *pool;
OFMutableArray OF_GENERIC(OFString *) *array;
bool done = false, endsWithEmpty;
OFString *path;
if (_URLEncodedPath == nil)
if (_percentEncodedPath == nil)
return;
pool = objc_autoreleasePoolPush();
array = [[[_URLEncodedPath
array = [[[_percentEncodedPath
componentsSeparatedByString: @"/"] mutableCopy] autorelease];
if ([array.firstObject length] != 0)
@throw [OFInvalidFormatException exception];
endsWithEmpty = ([array.lastObject length] == 0);
|
︙ | | |
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
-
+
-
+
|
if (endsWithEmpty)
[array addObject: @""];
path = [array componentsJoinedByString: @"/"];
if (path.length == 0)
path = @"/";
[self setURLEncodedPath: path];
[self setPercentEncodedPath: path];
objc_autoreleasePoolPop(pool);
}
- (void)makeImmutable
{
object_setClass(self, [OFURL class]);
object_setClass(self, [OFURI class]);
}
@end
|
Modified src/OFSecureData.h
from [a1ea7044b7]
to [9dc679ab94].
︙ | | |
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
-
+
|
+ (instancetype)dataWithItemsNoCopy: (void *)items
count: (size_t)count
itemSize: (size_t)itemSize
freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE;
#ifdef OF_HAVE_FILES
+ (instancetype)dataWithContentsOfFile: (OFString *)path OF_UNAVAILABLE;
#endif
+ (instancetype)dataWithContentsOfURL: (OFURL *)URL OF_UNAVAILABLE;
+ (instancetype)dataWithContentsOfURI: (OFURI *)URI OF_UNAVAILABLE;
+ (instancetype)dataWithStringRepresentation: (OFString *)string OF_UNAVAILABLE;
+ (instancetype)dataWithBase64EncodedString: (OFString *)string OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFSecureData with `count` items of
* item size 1, all set to zero.
*
|
︙ | | |
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
-
+
|
- (instancetype)initWithItemsNoCopy: (void *)items
count: (size_t)count
itemSize: (size_t)itemSize
freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE;
#ifdef OF_HAVE_FILES
- (instancetype)initWithContentsOfFile: (OFString *)path OF_UNAVAILABLE;
#endif
- (instancetype)initWithContentsOfURL: (OFURL *)URL OF_UNAVAILABLE;
- (instancetype)initWithContentsOfURI: (OFURI *)URI OF_UNAVAILABLE;
- (instancetype)initWithStringRepresentation: (OFString *)string OF_UNAVAILABLE;
- (instancetype)initWithBase64EncodedString: (OFString *)string OF_UNAVAILABLE;
- (instancetype)initWithSerialization: (OFXMLElement *)element OF_UNAVAILABLE;
/**
* @brief Returns a specific item of the OFSecureData.
*
|
︙ | | |
183
184
185
186
187
188
189
190
191
192
193
194
195
|
183
184
185
186
187
188
189
190
191
192
193
194
195
|
-
+
|
- (void)zero;
- (OFString *)stringRepresentation OF_UNAVAILABLE;
- (OFString *)stringByBase64Encoding OF_UNAVAILABLE;
#ifdef OF_HAVE_FILES
- (void)writeToFile: (OFString *)path OF_UNAVAILABLE;
#endif
- (void)writeToURL: (OFURL *)URL OF_UNAVAILABLE;
- (void)writeToURI: (OFURI *)URI OF_UNAVAILABLE;
- (OFXMLElement *)XMLElementBySerializing OF_UNAVAILABLE;
- (OFData *)messagePackRepresentation OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFSecureData.m
from [ea6060539c]
to [7420c1ca0e].
︙ | | |
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
-
+
|
#ifdef OF_HAVE_FILES
+ (instancetype)dataWithContentsOfFile: (OFString *)path
{
OF_UNRECOGNIZED_SELECTOR
}
#endif
+ (instancetype)dataWithContentsOfURL: (OFURL *)URL
+ (instancetype)dataWithContentsOfURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)dataWithStringRepresentation: (OFString *)string
{
OF_UNRECOGNIZED_SELECTOR
|
︙ | | |
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
-
+
|
#ifdef OF_HAVE_FILES
- (instancetype)initWithContentsOfFile: (OFString *)path
{
OF_INVALID_INIT_METHOD
}
#endif
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithStringRepresentation: (OFString *)string
{
OF_INVALID_INIT_METHOD
|
︙ | | |
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
-
+
|
#ifdef OF_HAVE_FILES
- (void)writeToFile: (OFString *)path
{
OF_UNRECOGNIZED_SELECTOR
}
#endif
- (void)writeToURL: (OFURL *)URL
- (void)writeToURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFXMLElement *)XMLElementBySerializing
{
OF_UNRECOGNIZED_SELECTOR
|
︙ | | |
Modified src/OFString+PathAdditions.h
from [2a2be8d086]
to [01351c2d45].
︙ | | |
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
-
-
-
-
-
+
+
+
+
+
|
*
* @param extension The extension to append
* @return A new, autoreleased OFString with the path extension appended
*/
- (OFString *)stringByAppendingPathExtension: (OFString *)extension;
- (bool)of_isDirectoryPath;
- (OFString *)of_pathToURLPathWithURLEncodedHost:
(OFString *__autoreleasing _Nullable *_Nonnull)URLEncodedHost;
- (OFString *)of_URLPathToPathWithURLEncodedHost:
(nullable OFString *)URLEncodedHost;
- (OFString *)of_pathComponentToURLPathComponent;
- (OFString *)of_pathToURIPathWithPercentEncodedHost:
(OFString *__autoreleasing _Nullable *_Nonnull)percentEncodedHost;
- (OFString *)of_URIPathToPathWithPercentEncodedHost:
(nullable OFString *)percentEncodedHost;
- (OFString *)of_pathComponentToURIPathComponent;
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFString+URLEncoding.h
[b50441492b]
to src/OFString+PercentEncoding.h
[ffc40e003e].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFCharacterSet;
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_URLEncoding_reference;
extern int _OFString_PercentEncoding_reference;
#ifdef __cplusplus
}
#endif
@interface OFString (URLEncoding)
@interface OFString (PercentEncoding)
/**
* @brief The string as an URL decoded string.
* @brief The string with percent-encoding removed.
*/
@property (readonly, nonatomic) OFString *stringByURLDecoding;
@property (readonly, nonatomic) OFString *stringByRemovingPercentEncoding;
/**
* @brief Encodes a string for use in a URL, but does not escape the specified
* allowed characters.
* @brief Percent-encodes a string for use in a URI, but does not escape the
* specified allowed characters.
*
* @param allowedCharacters A character set of characters that should not be
* escaped
*
* @return A new autoreleased string
*/
- (OFString *)stringByURLEncodingWithAllowedCharacters:
- (OFString *)stringByAddingPercentEncodingWithAllowedCharacters:
(OFCharacterSet *)allowedCharacters;
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFString+URLEncoding.m
[7c362d8c35]
to src/OFString+PercentEncoding.m
[46a599b120].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
+
-
+
-
-
+
+
|
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#import "OFString+URLEncoding.h"
#import "OFString+PercentEncoding.h"
#import "OFCharacterSet.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidEncodingException.h"
#import "OFOutOfMemoryException.h"
/* Reference for static linking */
int _OFString_URLEncoding_reference;
int _OFString_PercentEncoding_reference;
@implementation OFString (URLEncoding)
- (OFString *)stringByURLEncodingWithAllowedCharacters:
@implementation OFString (PercentEncoding)
- (OFString *)stringByAddingPercentEncodingWithAllowedCharacters:
(OFCharacterSet *)allowedCharacters
{
OFMutableString *ret = [OFMutableString string];
void *pool = objc_autoreleasePoolPush();
const OFUnichar *characters = self.characters;
size_t length = self.length;
bool (*characterIsMember)(id, SEL, OFUnichar) =
|
︙ | | |
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
-
+
|
}
objc_autoreleasePoolPop(pool);
return ret;
}
- (OFString *)stringByURLDecoding
- (OFString *)stringByRemovingPercentEncoding
{
void *pool = objc_autoreleasePoolPush();
const char *string = self.UTF8String;
size_t length = self.UTF8StringLength;
char *retCString;
char byte = 0;
int state = 0;
|
︙ | | |
Modified src/OFString.h
from [d0122c5cef]
to [9816b06102].
︙ | | |
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
-
+
|
*/
typedef void (^OFStringLineEnumerationBlock)(OFString *line, bool *stop);
#endif
#ifdef __OBJC__
@class OFArray OF_GENERIC(ObjectType);
@class OFCharacterSet;
@class OFURL;
@class OFURI;
/**
* @class OFString OFString.h ObjFW/OFString.h
*
* @brief A class for handling strings.
*/
@interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing,
|
︙ | | |
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
|
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* @return A new autoreleased OFString
*/
+ (instancetype)stringWithContentsOfFile: (OFString *)path
encoding: (OFStringEncoding)encoding;
# endif
/**
* @brief Creates a new OFString with the contents of the specified URL.
* @brief Creates a new OFString with the contents of the specified URI.
*
* If the URL's scheme is file, it tries UTF-8 encoding.
* If the URI's scheme is file, it tries UTF-8 encoding.
*
* If the URL's scheme is http(s), it tries to detect the encoding from the HTTP
* If the URI's scheme is http(s), it tries to detect the encoding from the HTTP
* headers. If it could not detect the encoding using the HTTP headers, it tries
* UTF-8.
*
* @param URL The URL to the contents for the string
* @param URI The URI to the contents for the string
* @return A new autoreleased OFString
*/
+ (instancetype)stringWithContentsOfURL: (OFURL *)URL;
+ (instancetype)stringWithContentsOfURI: (OFURI *)URI;
/**
* @brief Creates a new OFString with the contents of the specified URL in the
* @brief Creates a new OFString with the contents of the specified URI in the
* specified encoding.
*
* @param URL The URL to the contents for the string
* @param URI The URI to the contents for the string
* @param encoding The encoding to assume
* @return A new autoreleased OFString
*/
+ (instancetype)stringWithContentsOfURL: (OFURL *)URL
+ (instancetype)stringWithContentsOfURI: (OFURI *)URI
encoding: (OFStringEncoding)encoding;
/**
* @brief Initializes an already allocated OFString from a UTF-8 encoded C
* string.
*
* @param UTF8String A UTF-8 encoded C string to initialize the OFString with
|
︙ | | |
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
|
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
*/
- (instancetype)initWithContentsOfFile: (OFString *)path
encoding: (OFStringEncoding)encoding;
# endif
/**
* @brief Initializes an already allocated OFString with the contents of the
* specified URL.
* specified URI.
*
* If the URL's scheme is file, it tries UTF-8 encoding.
* If the URI's scheme is file, it tries UTF-8 encoding.
*
* If the URL's scheme is http(s), it tries to detect the encoding from the HTTP
* If the URI's scheme is http(s), it tries to detect the encoding from the HTTP
* headers. If it could not detect the encoding using the HTTP headers, it tries
* UTF-8.
*
* @param URL The URL to the contents for the string
* @param URI The URI to the contents for the string
* @return An initialized OFString
*/
- (instancetype)initWithContentsOfURL: (OFURL *)URL;
- (instancetype)initWithContentsOfURI: (OFURI *)URI;
/**
* @brief Initializes an already allocated OFString with the contents of the
* specified URL in the specified encoding.
* specified URI in the specified encoding.
*
* @param URL The URL to the contents for the string
* @param URI The URI to the contents for the string
* @param encoding The encoding to assume
* @return An initialized OFString
*/
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
encoding: (OFStringEncoding)encoding;
/**
* @brief Writes the OFString into the specified C string with the specified
* encoding.
*
* @param cString The C string to write into
|
︙ | | |
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
|
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
|
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
* @param path The path of the file to write to
* @param encoding The encoding to use to write the string into the file
*/
- (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding;
# endif
/**
* @brief Writes the string to the specified URL using UTF-8 encoding.
* @brief Writes the string to the specified URI using UTF-8 encoding.
*
* @param URL The URL to write to
* @param URI The URI to write to
*/
- (void)writeToURL: (OFURL *)URL;
- (void)writeToURI: (OFURI *)URI;
/**
* @brief Writes the string to the specified URL using the specified encoding.
* @brief Writes the string to the specified URI using the specified encoding.
*
* @param URL The URL to write to
* @param encoding The encoding to use to write the string to the URL
* @param URI The URI to write to
* @param encoding The encoding to use to write the string to the URI
*/
- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding;
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
# ifdef OF_HAVE_BLOCKS
/**
* Enumerates all lines in the receiver using the specified block.
*
* @brief block The block to call for each line
*/
|
︙ | | |
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
|
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
|
-
-
-
+
+
+
|
#include "OFMutableString.h"
#ifdef __OBJC__
# import "OFString+CryptographicHashing.h"
# import "OFString+JSONParsing.h"
# ifdef OF_HAVE_FILES
# import "OFString+PathAdditions.h"
# endif
# import "OFString+PropertyListParsing.h"
# import "OFString+Serialization.h"
# import "OFString+URLEncoding.h"
# import "OFString+PercentEncoding.h"
# import "OFString+PropertyListParsing.h"
# import "OFString+Serialization.h"
# import "OFString+XMLEscaping.h"
# import "OFString+XMLUnescaping.h"
#endif
#if defined(__OBJC__) && !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
/*
* Very *ugly* hack required for string boxing literals to work.
|
︙ | | |
Modified src/OFString.m
from [17aaf02040]
to [0e44856721].
︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
-
+
+
|
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFLocale.h"
#import "OFStream.h"
#import "OFSystemInfo.h"
#import "OFURL.h"
#import "OFURLHandler.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFUTF8String.h"
#import "OFUTF8String+Private.h"
#import "OFXMLElement.h"
#import "OFGetItemAttributesFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
|
︙ | | |
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
+
-
|
_references_to_categories_of_OFString(void)
{
_OFString_CryptographicHashing_reference = 1;
_OFString_JSONParsing_reference = 1;
#ifdef OF_HAVE_FILES
_OFString_PathAdditions_reference = 1;
#endif
_OFString_PercentEncoding_reference = 1;
_OFString_PropertyListParsing_reference = 1;
_OFString_Serialization_reference = 1;
_OFString_URLEncoding_reference = 1;
_OFString_XMLEscaping_reference = 1;
_OFString_XMLUnescaping_reference = 1;
}
void
_reference_to_OFConstantString(void)
{
|
︙ | | |
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
|
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
|
-
+
-
+
-
+
-
+
|
encoding: (OFStringEncoding)encoding
{
return (id)[[OFUTF8String alloc] initWithContentsOfFile: path
encoding: encoding];
}
#endif
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
{
return (id)[[OFUTF8String alloc] initWithContentsOfURL: URL];
return (id)[[OFUTF8String alloc] initWithContentsOfURI: URI];
}
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
encoding: (OFStringEncoding)encoding
{
return (id)[[OFUTF8String alloc] initWithContentsOfURL: URL
return (id)[[OFUTF8String alloc] initWithContentsOfURI: URI
encoding: encoding];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFUTF8String alloc] initWithSerialization: element];
}
|
︙ | | |
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
|
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
|
-
+
-
+
-
+
-
+
|
encoding: (OFStringEncoding)encoding
{
return [[[self alloc] initWithContentsOfFile: path
encoding: encoding] autorelease];
}
#endif
+ (instancetype)stringWithContentsOfURL: (OFURL *)URL
+ (instancetype)stringWithContentsOfURI: (OFURI *)URI
{
return [[[self alloc] initWithContentsOfURL: URL] autorelease];
return [[[self alloc] initWithContentsOfURI: URI] autorelease];
}
+ (instancetype)stringWithContentsOfURL: (OFURL *)URL
+ (instancetype)stringWithContentsOfURI: (OFURI *)URI
encoding: (OFStringEncoding)encoding
{
return [[[self alloc] initWithContentsOfURL: URL
return [[[self alloc] initWithContentsOfURI: URI
encoding: encoding] autorelease];
}
- (instancetype)init
{
if ([self isMemberOfClass: [OFString class]]) {
@try {
|
︙ | | |
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
|
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
|
-
+
-
+
-
+
-
+
|
}
}
return self;
}
#endif
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
{
return [self initWithContentsOfURL: URL
return [self initWithContentsOfURI: URI
encoding: OFStringEncodingAutodetect];
}
- (instancetype)initWithContentsOfURL: (OFURL *)URL
- (instancetype)initWithContentsOfURI: (OFURI *)URI
encoding: (OFStringEncoding)encoding
{
void *pool = objc_autoreleasePoolPush();
OFData *data;
@try {
data = [OFData dataWithContentsOfURL: URL];
data = [OFData dataWithContentsOfURI: URI];
} @catch (id e) {
[self release];
@throw e;
}
/* FIXME: Detect encoding where we can. */
if (encoding == OFStringEncodingAutodetect)
|
︙ | | |
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
|
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
|
-
+
-
+
-
+
-
+
|
void *pool = objc_autoreleasePoolPush();
OFFile *file = [OFFile fileWithPath: path mode: @"w"];
[file writeString: self encoding: encoding];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)writeToURL: (OFURL *)URL
- (void)writeToURI: (OFURI *)URI
{
[self writeToURL: URL encoding: OFStringEncodingUTF8];
[self writeToURI: URI encoding: OFStringEncodingUTF8];
}
- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
{
void *pool = objc_autoreleasePoolPush();
OFStream *stream;
stream = [OFURLHandler openItemAtURL: URL mode: @"w"];
stream = [OFURIHandler openItemAtURI: URI mode: @"w"];
[stream writeString: self encoding: encoding];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block
|
︙ | | |
Modified src/OFSystemInfo.h
from [b9e5001c12]
to [8b4f866788].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-
+
-
-
-
+
+
+
|
*/
#import "OFObject.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFSystemInfo OFSystemInfo.h ObjFW/OFSystemInfo.h
*
* @brief A class for querying information about the system.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFSystemInfo: OFObject
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic) size_t pageSize;
@property (class, readonly, nonatomic) size_t numberOfCPUs;
@property (class, readonly, nonatomic) OFString *ObjFWVersion;
@property (class, readonly, nonatomic) unsigned short ObjFWVersionMajor;
@property (class, readonly, nonatomic) unsigned short ObjFWVersionMinor;
@property (class, readonly, nullable, nonatomic) OFString *operatingSystemName;
@property (class, readonly, nullable, nonatomic)
OFString *operatingSystemVersion;
@property (class, readonly, nullable, nonatomic) OFURL *userDataURL;
@property (class, readonly, nullable, nonatomic) OFURL *userConfigURL;
@property (class, readonly, nullable, nonatomic) OFURL *temporaryDirectoryURL;
@property (class, readonly, nullable, nonatomic) OFURI *userDataURI;
@property (class, readonly, nullable, nonatomic) OFURI *userConfigURI;
@property (class, readonly, nullable, nonatomic) OFURI *temporaryDirectoryURI;
@property (class, readonly, nullable, nonatomic) OFString *CPUVendor;
@property (class, readonly, nullable, nonatomic) OFString *CPUModel;
# if defined(OF_X86_64) || defined(OF_X86) || defined(DOXYGEN)
@property (class, readonly, nonatomic) bool supportsMMX;
@property (class, readonly, nonatomic) bool supportsSSE;
@property (class, readonly, nonatomic) bool supportsSSE2;
@property (class, readonly, nonatomic) bool supportsSSE3;
|
︙ | | |
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
-
+
-
+
-
+
|
* On macOS and iOS, it uses the `NSApplicationSupportDirectory` directory.@n
* On Windows, it uses the `APPDATA` environment variable.@n
* On Haiku, it uses the `B_USER_SETTINGS_DIRECTORY` directory.@n
* On AmigaOS and MorphOS, it returns `PROGDIR:`.
*
* @return The path where user data for the application can be stored
*/
+ (nullable OFURL *)userDataURL;
+ (nullable OFURI *)userDataURI;
/**
* @brief Returns the path where user configuration for the application can be
* stored.
*
* On UNIX systems, this adheres to the XDG Base Directory specification.@n
* On macOS and iOS, it uses the `Preferences` directory inside of
* `NSLibraryDirectory` directory.@n
* On Windows, it uses the `APPDATA` environment variable.@n
* On Haiku, it uses the `B_USER_SETTINGS_DIRECTORY` directory.
* On AmigaOS and MorphOS, it returns `PROGDIR:`.
*
* @return The path where user configuration for the application can be stored
*/
+ (nullable OFURL *)userConfigURL;
+ (nullable OFURI *)userConfigURI;
/**
* @brief Returns a path where temporary files for can be stored.
*
* If possible, returns a temporary directory for the user, otherwise returns a
* global temporary directory.
*
* On UNIX systems, this adheres to the XDG Base Directory specification and
* returns `/tmp` if `XDG_RUNTIME_DIR` is not set.@n
* On macOS and iOS, this uses `_CS_DARWIN_USER_TEMP_DIR`, falling back to
* `/tmp` if this fails.@n
* On Windows, it uses `GetTempPath`.@n
* On Haiku, it uses the `B_SYSTEM_TEMP_DIRECTORY` directory.
* On AmigaOS and MorphOS, it returns `T:`.
*
* @return A path where temporary files can be stored
*/
+ (nullable OFURL *)temporaryDirectoryURL;
+ (nullable OFURI *)temporaryDirectoryURI;
/**
* @brief Returns the vendor of the CPU.
*
* If the vendor could not be determined, `nil` is returned instead.
*
* @return The vendor of the CPU
|
︙ | | |
Modified src/OFSystemInfo.m
from [08b6db7f62]
to [fb8661ad24].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
+
|
#import "OFSystemInfo.h"
#import "OFApplication.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFLocale.h"
#import "OFOnce.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
#if defined(OF_MACOS) || defined(OF_IOS)
# ifdef HAVE_SYSDIR_H
# include <sysdir.h>
# endif
#endif
#ifdef OF_WINDOWS
|
︙ | | |
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
-
+
-
+
|
operatingSystemVersion = [[OFString alloc]
initWithCString: utsname.release
encoding: [OFLocale encoding]];
#endif
}
#ifdef OF_NINTENDO_SWITCH
static OFURL *tmpFSURL = nil;
static OFURI *tmpFSURI = nil;
static void
mountTmpFS(void)
{
if (R_SUCCEEDED(fsdevMountTemporaryStorage("tmpfs")))
tmpFSURL = [[OFURL alloc] initFileURLWithPath: @"tmpfs:/"
tmpFSURI = [[OFURI alloc] initFileURIWithPath: @"tmpfs:/"
isDirectory: true];
}
#endif
#if defined(OF_X86_64) || defined(OF_X86)
static OF_INLINE struct X86Regs OF_CONST_FUNC
x86CPUID(uint32_t eax, uint32_t ecx)
|
︙ | | |
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
-
+
|
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initOperatingSystemVersion);
return operatingSystemVersion;
}
+ (OFURL *)userDataURL
+ (OFURI *)userDataURI
{
#ifdef OF_HAVE_FILES
# if defined(OF_MACOS) || defined(OF_IOS)
char pathC[PATH_MAX];
OFMutableString *path;
# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION
|
︙ | | |
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
[path deleteCharactersInRange: OFMakeRange(0, 1)];
[path insertString: home atIndex: 0];
}
[path makeImmutable];
return [OFURL fileURLWithPath: path isDirectory: true];
return [OFURI fileURIWithPath: path isDirectory: true];
# elif defined(OF_WINDOWS)
OFDictionary *env = [OFApplication environment];
OFString *appData;
if ((appData = [env objectForKey: @"APPDATA"]) == nil)
return nil;
return [OFURL fileURLWithPath: appData isDirectory: true];
return [OFURI fileURIWithPath: appData isDirectory: true];
# elif defined(OF_HAIKU)
char pathC[PATH_MAX];
if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false,
pathC, PATH_MAX) != B_OK)
return nil;
return [OFURL fileURLWithPath: [OFString stringWithUTF8String: pathC]
return [OFURI fileURIWithPath: [OFString stringWithUTF8String: pathC]
isDirectory: true];
# elif defined(OF_AMIGAOS)
return [OFURL fileURLWithPath: @"PROGDIR:" isDirectory: true];
return [OFURI fileURIWithPath: @"PROGDIR:" isDirectory: true];
# else
OFDictionary *env = [OFApplication environment];
OFString *var;
OFURL *URL;
OFURI *URI;
void *pool;
if ((var = [env objectForKey: @"XDG_DATA_HOME"]) != nil &&
var.length > 0)
return [OFURL fileURLWithPath: var isDirectory: true];
return [OFURI fileURIWithPath: var isDirectory: true];
if ((var = [env objectForKey: @"HOME"]) == nil)
return nil;
pool = objc_autoreleasePoolPush();
var = [OFString pathWithComponents: [OFArray arrayWithObjects:
var, @".local", @"share", nil]];
URL = [[OFURL alloc] initFileURLWithPath: var isDirectory: true];
URI = [[OFURI alloc] initFileURIWithPath: var isDirectory: true];
objc_autoreleasePoolPop(pool);
return [URL autorelease];
return [URI autorelease];
# endif
#else
return nil;
#endif
}
+ (OFURL *)userConfigURL
+ (OFURI *)userConfigURI
{
#ifdef OF_HAVE_FILES
# if defined(OF_MACOS) || defined(OF_IOS)
char pathC[PATH_MAX];
OFMutableString *path;
# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION
|
︙ | | |
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
|
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
[path deleteCharactersInRange: OFMakeRange(0, 1)];
[path insertString: home atIndex: 0];
}
[path appendString: @"/Preferences"];
[path makeImmutable];
return [OFURL fileURLWithPath: path isDirectory: true];
return [OFURI fileURIWithPath: path isDirectory: true];
# elif defined(OF_WINDOWS)
OFDictionary *env = [OFApplication environment];
OFString *appData;
if ((appData = [env objectForKey: @"APPDATA"]) == nil)
return nil;
return [OFURL fileURLWithPath: appData isDirectory: true];
return [OFURI fileURIWithPath: appData isDirectory: true];
# elif defined(OF_HAIKU)
char pathC[PATH_MAX];
if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false,
pathC, PATH_MAX) != B_OK)
return nil;
return [OFURL fileURLWithPath: [OFString stringWithUTF8String: pathC]
return [OFURI fileURIWithPath: [OFString stringWithUTF8String: pathC]
isDirectory: true];
# elif defined(OF_AMIGAOS)
return [OFURL fileURLWithPath: @"PROGDIR:" isDirectory: true];
return [OFURI fileURIWithPath: @"PROGDIR:" isDirectory: true];
# else
OFDictionary *env = [OFApplication environment];
OFString *var;
if ((var = [env objectForKey: @"XDG_CONFIG_HOME"]) != nil &&
var.length > 0)
return [OFURL fileURLWithPath: var isDirectory: true];
return [OFURI fileURIWithPath: var isDirectory: true];
if ((var = [env objectForKey: @"HOME"]) == nil)
return nil;
var = [var stringByAppendingPathComponent: @".config"];
return [OFURL fileURLWithPath: var isDirectory: true];
return [OFURI fileURIWithPath: var isDirectory: true];
# endif
#else
return nil;
#endif
}
+ (OFURL *)temporaryDirectoryURL
+ (OFURI *)temporaryDirectoryURI
{
#ifdef OF_HAVE_FILES
# if defined(OF_MACOS) || defined(OF_IOS)
char buffer[PATH_MAX];
size_t length;
OFString *path;
if ((length = confstr(_CS_DARWIN_USER_TEMP_DIR, buffer, PATH_MAX)) == 0)
return [OFURL fileURLWithPath: @"/tmp" isDirectory: true];
return [OFURI fileURIWithPath: @"/tmp" isDirectory: true];
path = [OFString stringWithCString: buffer
encoding: [OFLocale encoding]
length: length - 1];
return [OFURL fileURLWithPath: path isDirectory: true];
return [OFURI fileURIWithPath: path isDirectory: true];
# elif defined(OF_WINDOWS)
OFString *path;
if ([self isWindowsNT]) {
wchar_t buffer[PATH_MAX];
if (!GetTempPathW(PATH_MAX, buffer))
return nil;
path = [OFString stringWithUTF16String: buffer];
} else {
char buffer[PATH_MAX];
if (!GetTempPathA(PATH_MAX, buffer))
return nil;
path = [OFString stringWithCString: buffer
encoding: [OFLocale encoding]];
}
return [OFURL fileURLWithPath: path isDirectory: true];
return [OFURI fileURIWithPath: path isDirectory: true];
# elif defined(OF_HAIKU)
char pathC[PATH_MAX];
if (find_directory(B_SYSTEM_TEMP_DIRECTORY, 0, false,
pathC, PATH_MAX) != B_OK)
return nil;
return [OFURL fileURLWithPath: [OFString stringWithUTF8String: pathC]
return [OFURI fileURIWithPath: [OFString stringWithUTF8String: pathC]
isDirectory: true];
# elif defined(OF_AMIGAOS)
return [OFURL fileURLWithPath: @"T:" isDirectory: true];
return [OFURI fileURIWithPath: @"T:" isDirectory: true];
# elif defined(OF_MSDOS)
OFString *path = [[OFApplication environment] objectForKey: @"TEMP"];
if (path == nil)
return nil;
return [OFURL fileURLWithPath: path isDirectory: true];
return [OFURI fileURIWithPath: path isDirectory: true];
# elif defined(OF_MINT)
return [OFURL fileURLWithPath: @"u:\\tmp" isDirectory: true];
return [OFURI fileURIWithPath: @"u:\\tmp" isDirectory: true];
# elif defined(OF_NINTENDO_SWITCH)
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, mountTmpFS);
return tmpFSURL;
return tmpFSURI;
# else
OFString *path =
[[OFApplication environment] objectForKey: @"XDG_RUNTIME_DIR"];
if (path != nil)
return [OFURL fileURLWithPath: path];
return [OFURI fileURIWithPath: path];
return [OFURL fileURLWithPath: @"/tmp"];
return [OFURI fileURIWithPath: @"/tmp"];
# endif
#else
return nil;
#endif
}
+ (OFString *)CPUVendor
|
︙ | | |
Modified src/OFTarArchive.h
from [3b0b749343]
to [8804d5e5f3].
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
+
|
#import "OFKernelEventObserver.h"
#import "OFString.h"
#import "OFTarArchiveEntry.h"
OF_ASSUME_NONNULL_BEGIN
@class OFStream;
@class OFURL;
@class OFURI;
/**
* @class OFTarArchive OFTarArchive.h ObjFW/OFTarArchive.h
*
* @brief A class for accessing and manipulating tar archives.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
-
+
-
+
|
* @return A new, autoreleased OFTarArchive
*/
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
/**
* @brief Creates a new OFTarArchive object with the specified file.
*
* @param URL The URL to the tar archive
* @param URI The URI to the tar archive
* @param mode The mode for the tar file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return A new, autoreleased OFTarArchive
*/
+ (instancetype)archiveWithURL: (OFURL *)URL mode: (OFString *)mode;
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFTarArchive object with the
* specified stream.
*
|
︙ | | |
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
-
+
-
+
|
- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated OFTarArchive object with the
* specified file.
*
* @param URL The URL to the tar archive
* @param URI The URI to the tar archive
* @param mode The mode for the tar file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return An initialized OFTarArchive
*/
- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode;
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode;
/**
* @brief Returns the next entry from the tar archive or `nil` if all entries
* have been read.
*
* @note This is only available in read mode.
*
|
︙ | | |
Modified src/OFTarArchive.m
from [640e7a1648]
to [859f5b3b09].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
+
|
#import "OFTarArchive.h"
#import "OFTarArchiveEntry.h"
#import "OFTarArchiveEntry+Private.h"
#import "OFDate.h"
#import "OFSeekableStream.h"
#import "OFStream.h"
#import "OFURLHandler.h"
#import "OFURIHandler.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"
|
︙ | | |
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
-
+
|
@synthesize encoding = _encoding;
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
}
+ (instancetype)archiveWithURL: (OFURL *)URL mode: (OFString *)mode
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode
{
return [[[self alloc] initWithURL: URL mode: mode] autorelease];
return [[[self alloc] initWithURI: URI mode: mode] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
-
+
-
+
-
+
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFStream *stream;
@try {
if ([mode isEqual: @"a"])
stream = [OFURLHandler openItemAtURL: URL mode: @"r+"];
stream = [OFURIHandler openItemAtURI: URI mode: @"r+"];
else
stream = [OFURLHandler openItemAtURL: URL mode: mode];
stream = [OFURIHandler openItemAtURI: URI mode: mode];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStream: stream mode: mode];
|
︙ | | |
Renamed and modified
src/OFURL.h
[c47b91b130]
to src/OFURI.h
[4aa8c42360].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
-
+
-
+
-
+
+
-
+
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
@class OFArray OF_GENERIC(ObjectType);
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFNumber;
@class OFString;
/**
* @class OFURL OFURL.h ObjFW/OFURL.h
* @class OFURI OFURI.h ObjFW/OFURI.h
*
* @brief A class for parsing URLs and accessing parts of it.
* @brief A class for parsing URIs and accessing parts of it.
*/
@interface OFURL: OFObject <OFCopying, OFMutableCopying, OFSerialization>
@interface OFURI: OFObject <OFCopying, OFMutableCopying, OFSerialization>
{
OFString *_Nullable _percentEncodedScheme;
OFString *_Nullable _URLEncodedScheme, *_Nullable _URLEncodedHost;
OFString *_Nullable _percentEncodedHost;
OFNumber *_Nullable _port;
OFString *_Nullable _URLEncodedUser, *_Nullable _URLEncodedPassword;
OFString *_Nullable _URLEncodedPath;
OFString *_Nullable _URLEncodedQuery, *_Nullable _URLEncodedFragment;
OF_RESERVE_IVARS(OFURL, 4)
OFString *_Nullable _percentEncodedUser;
OFString *_Nullable _percentEncodedPassword;
OFString *_Nullable _percentEncodedPath;
OFString *_Nullable _percentEncodedQuery;
OFString *_Nullable _percentEncodedFragment;
OF_RESERVE_IVARS(OFURI, 4)
}
/**
* @brief The scheme part of the URL.
* @brief The scheme part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *scheme;
/**
* @brief The scheme part of the URL in URL-encoded form.
* @brief The scheme part of the URI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *URLEncodedScheme;
OFString *percentEncodedScheme;
/**
* @brief The host part of the URL.
* @brief The host part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *host;
/**
* @brief The host part of the URL in URL-encoded form.
* @brief The host part of the URI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *URLEncodedHost;
OFString *percentEncodedHost;
/**
* @brief The port part of the URL.
* @brief The port part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFNumber *port;
/**
* @brief The user part of the URL.
* @brief The user part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *user;
/**
* @brief The user part of the URL in URL-encoded form.
* @brief The user part of the URI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *URLEncodedUser;
OFString *percentEncodedUser;
/**
* @brief The password part of the URL.
* @brief The password part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *password;
/**
* @brief The password part of the URL in URL-encoded form.
* @brief The password part of the URI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *URLEncodedPassword;
OFString *percentEncodedPassword;
/**
* @brief The path part of the URL.
* @brief The path part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *path;
/**
* @brief The path part of the URL in URL-encoded form.
* @brief The path part of the URI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *URLEncodedPath;
OFString *percentEncodedPath;
/**
* @brief The path of the URL split into components.
* @brief The path of the URI split into components.
*
* The first component must always be `/` to designate the root.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFArray OF_GENERIC(OFString *) *pathComponents;
/**
* @brief The last path component of the URL.
* @brief The last path component of the URI.
*
* Returns the empty string if the path is the root.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *lastPathComponent;
/**
* @brief The query part of the URL.
* @brief The query part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *query;
/**
* @brief The query part of the URL in URL-encoded form.
* @brief The query part of the URI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *URLEncodedQuery;
OFString *percentEncodedQuery;
/**
* @brief The query part of the URL as a dictionary.
* @brief The query part of the URI as a dictionary.
*
* For example, a query like `key1=value1&key2=value2` would correspond to the
* following dictionary:
*
* @{
* @"key1": @"value1",
* @"key2": @"value2"
* }
*
* @throw OFInvalidFormatException The query is not in the correct format
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFDictionary OF_GENERIC(OFString *, OFString *) *queryDictionary;
/**
* @brief The fragment part of the URL.
* @brief The fragment part of the URI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *fragment;
/**
* @brief The fragment part of the URL in URL-encoded form.
* @brief The fragment part of the URI in URI-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *URLEncodedFragment;
OFString *percentEncodedFragment;
/**
* @brief The URL as a string.
* @brief The URI as a string.
*/
@property (readonly, nonatomic) OFString *string;
/**
* @brief The URL with relative subpaths resolved.
* @brief The URI with relative subpaths resolved.
*/
@property (readonly, nonatomic) OFURL *URLByStandardizingPath;
@property (readonly, nonatomic) OFURI *URIByStandardizingPath;
#ifdef OF_HAVE_FILES
/**
* @brief The local file system representation for a file URL.
* @brief The local file system representation for a file URI.
*
* @note This only exists for URLs with the file scheme and throws an exception
* @note This only exists for URIs with the file scheme and throws an exception
* otherwise.
*
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
OFString *fileSystemRepresentation;
#endif
/**
* @brief Creates a new URL with the specified string.
* @brief Creates a new URI with the specified string.
*
* @param string A string describing a URL
* @return A new, autoreleased OFURL
* @throw OFInvalidFormatException The specified string is not a valid URL
* @param string A string describing a URI
* @return A new, autoreleased OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* string
*/
+ (instancetype)URLWithString: (OFString *)string;
+ (instancetype)URIWithString: (OFString *)string;
/**
* @brief Creates a new URL with the specified string relative to the
* specified URL.
* @brief Creates a new URI with the specified string relative to the
* specified URI.
*
* @param string A string describing a URL
* @param URL An URL to which the string is relative
* @return A new, autoreleased OFURL
* @throw OFInvalidFormatException The specified string is not a valid URL
* @param string A string describing a relative or absolute URI
* @param URI An URI to which the string is relative
* @return A new, autoreleased OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* string
*/
+ (instancetype)URLWithString: (OFString *)string relativeToURL: (OFURL *)URL;
+ (instancetype)URIWithString: (OFString *)string relativeToURI: (OFURI *)URI;
#ifdef OF_HAVE_FILES
/**
* @brief Creates a new URL with the specified local file path.
* @brief Creates a new URI with the specified local file path.
*
* If a directory exists at the specified path, a slash is appended if there is
* no slash yet.
*
* @param path The local file path
* @return A new, autoreleased OFURL
* @return A new, autoreleased OFURI
*/
+ (instancetype)fileURLWithPath: (OFString *)path;
+ (instancetype)fileURIWithPath: (OFString *)path;
/**
* @brief Creates a new URL with the specified local file path.
* @brief Creates a new URI with the specified local file path.
*
* @param path The local file path
* @param isDirectory Whether the path is a directory, in which case a slash is
* appened if there is no slash yet
* @return An initialized OFURL
* @return An initialized OFURI
*/
+ (instancetype)fileURLWithPath: (OFString *)path
+ (instancetype)fileURIWithPath: (OFString *)path
isDirectory: (bool)isDirectory;
#endif
/**
* @brief Initializes an already allocated OFURL with the specified string.
* @brief Initializes an already allocated OFURI with the specified string.
*
* @param string A string describing a URL
* @return An initialized OFURL
* @throw OFInvalidFormatException The specified string is not a valid URL
* @param string A string describing a URI
* @return An initialized OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* string
*/
- (instancetype)initWithString: (OFString *)string;
/**
* @brief Initializes an already allocated OFURL with the specified string and
* relative URL.
* @brief Initializes an already allocated OFURI with the specified string and
* relative URI.
*
* @param string A string describing a URL
* @param URL A URL to which the string is relative
* @return An initialized OFURL
* @throw OFInvalidFormatException The specified string is not a valid URL
* @param string A string describing a relative or absolute URI
* @param URI A URI to which the string is relative
* @return An initialized OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* string
*/
- (instancetype)initWithString: (OFString *)string relativeToURL: (OFURL *)URL;
- (instancetype)initWithString: (OFString *)string relativeToURI: (OFURI *)URI;
#ifdef OF_HAVE_FILES
/**
* @brief Initializes an already allocated OFURL with the specified local file
* @brief Initializes an already allocated OFURI with the specified local file
* path.
*
* If a directory exists at the specified path, a slash is appended if there is
* no slash yet.
*
* @param path The local file path
* @return An initialized OFURL
* @return An initialized OFURI
*/
- (instancetype)initFileURLWithPath: (OFString *)path;
- (instancetype)initFileURIWithPath: (OFString *)path;
/**
* @brief Initializes an already allocated OFURL with the specified local file
* @brief Initializes an already allocated OFURI with the specified local file
* path.
*
* @param path The local file path
* @param isDirectory Whether the path is a directory, in which case a slash is
* appened if there is no slash yet
* @return An initialized OFURL
* @return An initialized OFURI
*/
- (instancetype)initFileURLWithPath: (OFString *)path
- (instancetype)initFileURIWithPath: (OFString *)path
isDirectory: (bool)isDirectory;
#endif
/**
* @brief Returns a new URL with the specified path component appended.
* @brief Returns a new URI with the specified path component appended.
*
* If the URL is a file URL, the file system is queried whether the appended
* If the URI is a file URI, the file system is queried whether the appended
* component is a directory.
*
* @param component The path component to append. If it starts with the slash,
* the component is not appended, but replaces the path
* instead.
* @return A new URL with the specified path component appended
* @return A new URI with the specified path component appended
*/
- (OFURL *)URLByAppendingPathComponent: (OFString *)component;
- (OFURI *)URIByAppendingPathComponent: (OFString *)component;
/**
* @brief Returns a new URL with the specified path component appended.
* @brief Returns a new URI with the specified path component appended.
*
* @param component The path component to append. If it starts with the slash,
* the component is not appended, but replaces the path
* instead.
* @param isDirectory Whether the appended component is a directory, meaning
* that the URL path should have a trailing slash
* @return A new URL with the specified path component appended
* that the URI path should have a trailing slash
* @return A new URI with the specified path component appended
*/
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
- (OFURI *)URIByAppendingPathComponent: (OFString *)component
isDirectory: (bool)isDirectory;
@end
@interface OFCharacterSet (URLCharacterSets)
@interface OFCharacterSet (URICharacterSets)
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic)
OFCharacterSet *URLSchemeAllowedCharacterSet;
OFCharacterSet *URISchemeAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URLHostAllowedCharacterSet;
OFCharacterSet *URIHostAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URLUserAllowedCharacterSet;
OFCharacterSet *URIUserAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URLPasswordAllowedCharacterSet;
OFCharacterSet *URIPasswordAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URLPathAllowedCharacterSet;
OFCharacterSet *URIPathAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URLQueryAllowedCharacterSet;
OFCharacterSet *URIQueryAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URLQueryKeyValueAllowedCharacterSet;
OFCharacterSet *URIQueryKeyValueAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URLFragmentAllowedCharacterSet;
OFCharacterSet *URIFragmentAllowedCharacterSet;
#endif
/**
* @brief Returns the characters allowed in the scheme part of a URL.
* @brief Returns the characters allowed in the scheme part of a URI.
*
* @return The characters allowed in the scheme part of a URL.
* @return The characters allowed in the scheme part of a URI.
*/
+ (OFCharacterSet *)URLSchemeAllowedCharacterSet;
+ (OFCharacterSet *)URISchemeAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the host part of a URL.
* @brief Returns the characters allowed in the host part of a URI.
*
* @return The characters allowed in the host part of a URL.
* @return The characters allowed in the host part of a URI.
*/
+ (OFCharacterSet *)URLHostAllowedCharacterSet;
+ (OFCharacterSet *)URIHostAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the user part of a URL.
* @brief Returns the characters allowed in the user part of a URI.
*
* @return The characters allowed in the user part of a URL.
* @return The characters allowed in the user part of a URI.
*/
+ (OFCharacterSet *)URLUserAllowedCharacterSet;
+ (OFCharacterSet *)URIUserAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the password part of a URL.
* @brief Returns the characters allowed in the password part of a URI.
*
* @return The characters allowed in the password part of a URL.
* @return The characters allowed in the password part of a URI.
*/
+ (OFCharacterSet *)URLPasswordAllowedCharacterSet;
+ (OFCharacterSet *)URIPasswordAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the path part of a URL.
* @brief Returns the characters allowed in the path part of a URI.
*
* @return The characters allowed in the path part of a URL.
* @return The characters allowed in the path part of a URI.
*/
+ (OFCharacterSet *)URLPathAllowedCharacterSet;
+ (OFCharacterSet *)URIPathAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the query part of a URL.
* @brief Returns the characters allowed in the query part of a URI.
*
* @return The characters allowed in the query part of a URL.
* @return The characters allowed in the query part of a URI.
*/
+ (OFCharacterSet *)URLQueryAllowedCharacterSet;
+ (OFCharacterSet *)URIQueryAllowedCharacterSet;
/**
* @brief Returns the characters allowed in a key/value in the query part of a
* URL.
* URI.
*
* @return The characters allowed in a key/value in the query part of a URL.
* @return The characters allowed in a key/value in the query part of a URI.
*/
+ (OFCharacterSet *)URLQueryKeyValueAllowedCharacterSet;
+ (OFCharacterSet *)URIQueryKeyValueAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the fragment part of a URL.
* @brief Returns the characters allowed in the fragment part of a URI.
*
* @return The characters allowed in the fragment part of a URL.
* @return The characters allowed in the fragment part of a URI.
*/
+ (OFCharacterSet *)URLFragmentAllowedCharacterSet;
+ (OFCharacterSet *)URIFragmentAllowedCharacterSet;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern bool OFURLIsIPv6Host(OFString *host);
extern void OFURLVerifyIsEscaped(OFString *, OFCharacterSet *);
extern bool OFURIIsIPv6Host(OFString *host);
extern void OFURIVerifyIsEscaped(OFString *, OFCharacterSet *);
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
#import "OFMutableURL.h"
#import "OFMutableURI.h"
|
Renamed and modified
src/OFURL.m
[5340bb2772]
to src/OFURI.m
[f31f144d07].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
|
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#import "OFURL.h"
#import "OFURI.h"
#import "OFArray.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFileManager.h"
# import "OFFileURLHandler.h"
# import "OFFileURIHandler.h"
#endif
#import "OFNumber.h"
#import "OFOnce.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
@interface OFURLAllowedCharacterSetBase: OFCharacterSet
@interface OFURIAllowedCharacterSetBase: OFCharacterSet
@end
@interface OFURLAllowedCharacterSet: OFURLAllowedCharacterSetBase
@interface OFURIAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end
@interface OFURLSchemeAllowedCharacterSet: OFURLAllowedCharacterSetBase
@interface OFURISchemeAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end
@interface OFURLPathAllowedCharacterSet: OFURLAllowedCharacterSetBase
@interface OFURIPathAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end
@interface OFURLQueryOrFragmentAllowedCharacterSet: OFURLAllowedCharacterSetBase
@interface OFURIQueryOrFragmentAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end
@interface OFURLQueryKeyValueAllowedCharacterSet: OFURLAllowedCharacterSetBase
@interface OFURIQueryKeyValueAllowedCharacterSet: OFURIAllowedCharacterSetBase
@end
static OFCharacterSet *URLAllowedCharacterSet = nil;
static OFCharacterSet *URLSchemeAllowedCharacterSet = nil;
static OFCharacterSet *URLPathAllowedCharacterSet = nil;
static OFCharacterSet *URLQueryOrFragmentAllowedCharacterSet = nil;
static OFCharacterSet *URLQueryKeyValueAllowedCharacterSet = nil;
static OFCharacterSet *URIAllowedCharacterSet = nil;
static OFCharacterSet *URISchemeAllowedCharacterSet = nil;
static OFCharacterSet *URIPathAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryOrFragmentAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryKeyValueAllowedCharacterSet = nil;
static OFOnceControl URLAllowedCharacterSetOnce = OFOnceControlInitValue;
static OFOnceControl URLQueryOrFragmentAllowedCharacterSetOnce =
static OFOnceControl URIAllowedCharacterSetOnce = OFOnceControlInitValue;
static OFOnceControl URIQueryOrFragmentAllowedCharacterSetOnce =
OFOnceControlInitValue;
static void
initURLAllowedCharacterSet(void)
initURIAllowedCharacterSet(void)
{
URLAllowedCharacterSet = [[OFURLAllowedCharacterSet alloc] init];
URIAllowedCharacterSet = [[OFURIAllowedCharacterSet alloc] init];
}
static void
initURLSchemeAllowedCharacterSet(void)
initURISchemeAllowedCharacterSet(void)
{
URLSchemeAllowedCharacterSet =
[[OFURLSchemeAllowedCharacterSet alloc] init];
URISchemeAllowedCharacterSet =
[[OFURISchemeAllowedCharacterSet alloc] init];
}
static void
initURLPathAllowedCharacterSet(void)
initURIPathAllowedCharacterSet(void)
{
URLPathAllowedCharacterSet =
[[OFURLPathAllowedCharacterSet alloc] init];
URIPathAllowedCharacterSet =
[[OFURIPathAllowedCharacterSet alloc] init];
}
static void
initURLQueryOrFragmentAllowedCharacterSet(void)
initURIQueryOrFragmentAllowedCharacterSet(void)
{
URLQueryOrFragmentAllowedCharacterSet =
[[OFURLQueryOrFragmentAllowedCharacterSet alloc] init];
URIQueryOrFragmentAllowedCharacterSet =
[[OFURIQueryOrFragmentAllowedCharacterSet alloc] init];
}
static void
initURLQueryKeyValueAllowedCharacterSet(void)
initURIQueryKeyValueAllowedCharacterSet(void)
{
URLQueryKeyValueAllowedCharacterSet =
[[OFURLQueryKeyValueAllowedCharacterSet alloc] init];
URIQueryKeyValueAllowedCharacterSet =
[[OFURIQueryKeyValueAllowedCharacterSet alloc] init];
}
OF_DIRECT_MEMBERS
@interface OFInvertedCharacterSetWithoutPercent: OFCharacterSet
{
OFCharacterSet *_characterSet;
bool (*_characterIsMember)(id, SEL, OFUnichar);
}
- (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet;
@end
bool
OFURLIsIPv6Host(OFString *host)
OFURIIsIPv6Host(OFString *host)
{
const char *UTF8String = host.UTF8String;
bool hasColon = false;
while (*UTF8String != '\0') {
if (!OFASCIIIsDigit(*UTF8String) && *UTF8String != ':' &&
(*UTF8String < 'a' || *UTF8String > 'f') &&
(*UTF8String < 'A' || *UTF8String > 'F'))
return false;
if (*UTF8String == ':')
hasColon = true;
UTF8String++;
}
return hasColon;
}
@implementation OFURLAllowedCharacterSetBase
@implementation OFURIAllowedCharacterSetBase
- (instancetype)autorelease
{
return self;
}
- (instancetype)retain
{
return self;
}
- (void)release
{
}
- (unsigned int)retainCount
{
return OFMaxRetainCount;
}
@end
@implementation OFURLAllowedCharacterSet
@implementation OFURIAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
switch (character) {
case '-':
|
︙ | | |
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
-
+
-
+
|
return true;
default:
return false;
}
}
@end
@implementation OFURLSchemeAllowedCharacterSet
@implementation OFURISchemeAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
switch (character) {
case '+':
case '-':
case '.':
return true;
default:
return false;
}
}
@end
@implementation OFURLPathAllowedCharacterSet
@implementation OFURIPathAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
switch (character) {
case '-':
|
︙ | | |
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
-
+
|
return true;
default:
return false;
}
}
@end
@implementation OFURLQueryOrFragmentAllowedCharacterSet
@implementation OFURIQueryOrFragmentAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
switch (character) {
case '-':
|
︙ | | |
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
-
+
|
return true;
default:
return false;
}
}
@end
@implementation OFURLQueryKeyValueAllowedCharacterSet
@implementation OFURIQueryKeyValueAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
switch (character) {
case '-':
|
︙ | | |
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
|
{
return (character != '%' && !_characterIsMember(_characterSet,
@selector(characterIsMember:), character));
}
@end
void
OFURLVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet)
OFURIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet)
{
void *pool = objc_autoreleasePoolPush();
characterSet = [[[OFInvertedCharacterSetWithoutPercent alloc]
initWithCharacterSet: characterSet] autorelease];
if ([string indexOfCharacterFromSet: characterSet] != OFNotFound)
@throw [OFInvalidFormatException exception];
objc_autoreleasePoolPop(pool);
}
@implementation OFCharacterSet (URLCharacterSets)
+ (OFCharacterSet *)URLSchemeAllowedCharacterSet
@implementation OFCharacterSet (URICharacterSets)
+ (OFCharacterSet *)URISchemeAllowedCharacterSet
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initURLSchemeAllowedCharacterSet);
OFOnce(&onceControl, initURISchemeAllowedCharacterSet);
return URLSchemeAllowedCharacterSet;
return URISchemeAllowedCharacterSet;
}
+ (OFCharacterSet *)URLHostAllowedCharacterSet
+ (OFCharacterSet *)URIHostAllowedCharacterSet
{
OFOnce(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet);
OFOnce(&URIAllowedCharacterSetOnce, initURIAllowedCharacterSet);
return URLAllowedCharacterSet;
return URIAllowedCharacterSet;
}
+ (OFCharacterSet *)URLUserAllowedCharacterSet
+ (OFCharacterSet *)URIUserAllowedCharacterSet
{
OFOnce(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet);
OFOnce(&URIAllowedCharacterSetOnce, initURIAllowedCharacterSet);
return URLAllowedCharacterSet;
return URIAllowedCharacterSet;
}
+ (OFCharacterSet *)URLPasswordAllowedCharacterSet
+ (OFCharacterSet *)URIPasswordAllowedCharacterSet
{
OFOnce(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet);
OFOnce(&URIAllowedCharacterSetOnce, initURIAllowedCharacterSet);
return URLAllowedCharacterSet;
return URIAllowedCharacterSet;
}
+ (OFCharacterSet *)URLPathAllowedCharacterSet
+ (OFCharacterSet *)URIPathAllowedCharacterSet
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initURLPathAllowedCharacterSet);
OFOnce(&onceControl, initURIPathAllowedCharacterSet);
return URLPathAllowedCharacterSet;
return URIPathAllowedCharacterSet;
}
+ (OFCharacterSet *)URLQueryAllowedCharacterSet
+ (OFCharacterSet *)URIQueryAllowedCharacterSet
{
OFOnce(&URLQueryOrFragmentAllowedCharacterSetOnce,
initURLQueryOrFragmentAllowedCharacterSet);
OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce,
initURIQueryOrFragmentAllowedCharacterSet);
return URLQueryOrFragmentAllowedCharacterSet;
return URIQueryOrFragmentAllowedCharacterSet;
}
+ (OFCharacterSet *)URLQueryKeyValueAllowedCharacterSet
+ (OFCharacterSet *)URIQueryKeyValueAllowedCharacterSet
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initURLQueryKeyValueAllowedCharacterSet);
OFOnce(&onceControl, initURIQueryKeyValueAllowedCharacterSet);
return URLQueryKeyValueAllowedCharacterSet;
return URIQueryKeyValueAllowedCharacterSet;
}
+ (OFCharacterSet *)URLFragmentAllowedCharacterSet
+ (OFCharacterSet *)URIFragmentAllowedCharacterSet
{
OFOnce(&URLQueryOrFragmentAllowedCharacterSetOnce,
initURLQueryOrFragmentAllowedCharacterSet);
OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce,
initURIQueryOrFragmentAllowedCharacterSet);
return URLQueryOrFragmentAllowedCharacterSet;
return URIQueryOrFragmentAllowedCharacterSet;
}
@end
@implementation OFURL
+ (instancetype)URL
@implementation OFURI
+ (instancetype)URI
{
return [[[self alloc] init] autorelease];
}
+ (instancetype)URLWithString: (OFString *)string
+ (instancetype)URIWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
+ (instancetype)URLWithString: (OFString *)string
relativeToURL: (OFURL *)URL
+ (instancetype)URIWithString: (OFString *)string
relativeToURI: (OFURI *)URI
{
return [[[self alloc] initWithString: string
relativeToURL: URL] autorelease];
relativeToURI: URI] autorelease];
}
#ifdef OF_HAVE_FILES
+ (instancetype)fileURLWithPath: (OFString *)path
+ (instancetype)fileURIWithPath: (OFString *)path
{
return [[[self alloc] initFileURLWithPath: path] autorelease];
return [[[self alloc] initFileURIWithPath: path] autorelease];
}
+ (instancetype)fileURLWithPath: (OFString *)path
+ (instancetype)fileURIWithPath: (OFString *)path
isDirectory: (bool)isDirectory
{
return [[[self alloc] initFileURLWithPath: path
return [[[self alloc] initFileURIWithPath: path
isDirectory: isDirectory] autorelease];
}
#endif
- (instancetype)initWithString: (OFString *)string
{
char *UTF8String, *UTF8String2 = NULL;
|
︙ | | |
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
if (strncmp(tmp, "://", 3) != 0)
@throw [OFInvalidFormatException exception];
for (tmp2 = UTF8String; tmp2 < tmp; tmp2++)
*tmp2 = OFASCIIToLower(*tmp2);
_URLEncodedScheme = [[OFString alloc]
_percentEncodedScheme = [[OFString alloc]
initWithUTF8String: UTF8String
length: tmp - UTF8String];
OFURLVerifyIsEscaped(_URLEncodedScheme,
[OFCharacterSet URLSchemeAllowedCharacterSet]);
OFURIVerifyIsEscaped(_percentEncodedScheme,
[OFCharacterSet URISchemeAllowedCharacterSet]);
UTF8String = tmp + 3;
if ((tmp = strchr(UTF8String, '/')) != NULL) {
*tmp = '\0';
tmp++;
}
if ((tmp2 = strchr(UTF8String, '@')) != NULL) {
char *tmp3;
*tmp2 = '\0';
tmp2++;
if ((tmp3 = strchr(UTF8String, ':')) != NULL) {
*tmp3 = '\0';
tmp3++;
_URLEncodedUser = [[OFString alloc]
_percentEncodedUser = [[OFString alloc]
initWithUTF8String: UTF8String];
_URLEncodedPassword = [[OFString alloc]
_percentEncodedPassword = [[OFString alloc]
initWithUTF8String: tmp3];
OFURLVerifyIsEscaped(_URLEncodedPassword,
OFURIVerifyIsEscaped(_percentEncodedPassword,
[OFCharacterSet
URLPasswordAllowedCharacterSet]);
URIPasswordAllowedCharacterSet]);
} else
_URLEncodedUser = [[OFString alloc]
_percentEncodedUser = [[OFString alloc]
initWithUTF8String: UTF8String];
OFURLVerifyIsEscaped(_URLEncodedUser,
[OFCharacterSet URLUserAllowedCharacterSet]);
OFURIVerifyIsEscaped(_percentEncodedUser,
[OFCharacterSet URIUserAllowedCharacterSet]);
UTF8String = tmp2;
}
if (UTF8String[0] == '[') {
tmp2 = UTF8String++;
while (OFASCIIIsDigit(*UTF8String) ||
*UTF8String == ':' ||
(*UTF8String >= 'a' && *UTF8String <= 'f') ||
(*UTF8String >= 'A' && *UTF8String <= 'F'))
UTF8String++;
if (*UTF8String != ']')
@throw [OFInvalidFormatException exception];
UTF8String++;
_URLEncodedHost = [[OFString alloc]
_percentEncodedHost = [[OFString alloc]
initWithUTF8String: tmp2
length: UTF8String - tmp2];
if (*UTF8String == ':') {
OFString *portString;
tmp2 = ++UTF8String;
|
︙ | | |
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
|
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
|
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
|
isIPv6Host = true;
} else if ((tmp2 = strchr(UTF8String, ':')) != NULL) {
OFString *portString;
*tmp2 = '\0';
tmp2++;
_URLEncodedHost = [[OFString alloc]
_percentEncodedHost = [[OFString alloc]
initWithUTF8String: UTF8String];
portString = [OFString stringWithUTF8String: tmp2];
if (portString.unsignedLongLongValue > 65535)
@throw [OFInvalidFormatException exception];
_port = [[OFNumber alloc] initWithUnsignedShort:
portString.unsignedLongLongValue];
} else {
_URLEncodedHost = [[OFString alloc]
_percentEncodedHost = [[OFString alloc]
initWithUTF8String: UTF8String];
if (_URLEncodedHost.length == 0) {
[_URLEncodedHost release];
_URLEncodedHost = nil;
if (_percentEncodedHost.length == 0) {
[_percentEncodedHost release];
_percentEncodedHost = nil;
}
}
if (_URLEncodedHost != nil && !isIPv6Host)
OFURLVerifyIsEscaped(_URLEncodedHost,
[OFCharacterSet URLHostAllowedCharacterSet]);
if (_percentEncodedHost != nil && !isIPv6Host)
OFURIVerifyIsEscaped(_percentEncodedHost,
[OFCharacterSet URIHostAllowedCharacterSet]);
if ((UTF8String = tmp) != NULL) {
if ((tmp = strchr(UTF8String, '#')) != NULL) {
*tmp = '\0';
_URLEncodedFragment = [[OFString alloc]
_percentEncodedFragment = [[OFString alloc]
initWithUTF8String: tmp + 1];
OFURLVerifyIsEscaped(_URLEncodedFragment,
OFURIVerifyIsEscaped(_percentEncodedFragment,
[OFCharacterSet
URLFragmentAllowedCharacterSet]);
URIFragmentAllowedCharacterSet]);
}
if ((tmp = strchr(UTF8String, '?')) != NULL) {
*tmp = '\0';
_URLEncodedQuery = [[OFString alloc]
_percentEncodedQuery = [[OFString alloc]
initWithUTF8String: tmp + 1];
OFURLVerifyIsEscaped(_URLEncodedQuery,
OFURIVerifyIsEscaped(_percentEncodedQuery,
[OFCharacterSet
URLQueryAllowedCharacterSet]);
URIQueryAllowedCharacterSet]);
}
/*
* Some versions of GCC issue a false-positive warning
* (turned error) about a string overflow. This is a
* false positive because UTF8String is set to tmp
* above and tmp is either NULL or points *after* the
|
︙ | | |
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
|
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
|
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
|
#endif
UTF8String--;
*UTF8String = '/';
#if OF_GCC_VERSION >= 402
# pragma GCC diagnostic pop
#endif
_URLEncodedPath = [[OFString alloc]
_percentEncodedPath = [[OFString alloc]
initWithUTF8String: UTF8String];
OFURLVerifyIsEscaped(_URLEncodedPath,
[OFCharacterSet URLPathAllowedCharacterSet]);
OFURIVerifyIsEscaped(_percentEncodedPath,
[OFCharacterSet URIPathAllowedCharacterSet]);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
} @finally {
OFFreeMemory(UTF8String2);
}
return self;
}
- (instancetype)initWithString: (OFString *)string relativeToURL: (OFURL *)URL
- (instancetype)initWithString: (OFString *)string relativeToURI: (OFURI *)URI
{
char *UTF8String, *UTF8String2 = NULL;
if ([string containsString: @"://"])
return [self initWithString: string];
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
char *tmp;
_URLEncodedScheme = [URL->_URLEncodedScheme copy];
_URLEncodedHost = [URL->_URLEncodedHost copy];
_port = [URL->_port copy];
_URLEncodedUser = [URL->_URLEncodedUser copy];
_URLEncodedPassword = [URL->_URLEncodedPassword copy];
_percentEncodedScheme = [URI->_percentEncodedScheme copy];
_percentEncodedHost = [URI->_percentEncodedHost copy];
_port = [URI->_port copy];
_percentEncodedUser = [URI->_percentEncodedUser copy];
_percentEncodedPassword = [URI->_percentEncodedPassword copy];
UTF8String = UTF8String2 = OFStrDup(string.UTF8String);
if ((tmp = strchr(UTF8String, '#')) != NULL) {
*tmp = '\0';
_URLEncodedFragment = [[OFString alloc]
_percentEncodedFragment = [[OFString alloc]
initWithUTF8String: tmp + 1];
OFURLVerifyIsEscaped(_URLEncodedFragment,
[OFCharacterSet URLFragmentAllowedCharacterSet]);
OFURIVerifyIsEscaped(_percentEncodedFragment,
[OFCharacterSet URIFragmentAllowedCharacterSet]);
}
if ((tmp = strchr(UTF8String, '?')) != NULL) {
*tmp = '\0';
_URLEncodedQuery = [[OFString alloc]
_percentEncodedQuery = [[OFString alloc]
initWithUTF8String: tmp + 1];
OFURLVerifyIsEscaped(_URLEncodedQuery,
[OFCharacterSet URLQueryAllowedCharacterSet]);
OFURIVerifyIsEscaped(_percentEncodedQuery,
[OFCharacterSet URIQueryAllowedCharacterSet]);
}
if (*UTF8String == '/')
_URLEncodedPath = [[OFString alloc]
_percentEncodedPath = [[OFString alloc]
initWithUTF8String: UTF8String];
else {
OFString *relativePath =
[OFString stringWithUTF8String: UTF8String];
if ([URL->_URLEncodedPath hasSuffix: @"/"])
_URLEncodedPath = [[URL->_URLEncodedPath
if ([URI->_percentEncodedPath hasSuffix: @"/"])
_percentEncodedPath = [[URI->_percentEncodedPath
stringByAppendingString: relativePath]
copy];
else {
OFMutableString *path = [OFMutableString
stringWithString:
(URL->_URLEncodedPath != nil
? URL->_URLEncodedPath
(URI->_percentEncodedPath != nil
? URI->_percentEncodedPath
: @"/")];
OFRange range = [path
rangeOfString: @"/"
options: OFStringSearchBackwards];
if (range.location == OFNotFound)
@throw [OFInvalidFormatException
exception];
range.location++;
range.length = path.length - range.location;
[path replaceCharactersInRange: range
withString: relativePath];
[path makeImmutable];
_URLEncodedPath = [path copy];
_percentEncodedPath = [path copy];
}
}
OFURLVerifyIsEscaped(_URLEncodedPath,
[OFCharacterSet URLPathAllowedCharacterSet]);
OFURIVerifyIsEscaped(_percentEncodedPath,
[OFCharacterSet URIPathAllowedCharacterSet]);
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
} @finally {
OFFreeMemory(UTF8String2);
}
return self;
}
#ifdef OF_HAVE_FILES
- (instancetype)initFileURLWithPath: (OFString *)path
- (instancetype)initFileURIWithPath: (OFString *)path
{
bool isDirectory;
@try {
void *pool = objc_autoreleasePoolPush();
isDirectory = [path of_isDirectoryPath];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
self = [self initFileURLWithPath: path isDirectory: isDirectory];
self = [self initFileURIWithPath: path isDirectory: isDirectory];
return self;
}
- (instancetype)initFileURLWithPath: (OFString *)path
- (instancetype)initFileURIWithPath: (OFString *)path
isDirectory: (bool)isDirectory
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFString *URLEncodedHost = nil;
OFString *percentEncodedHost = nil;
if (!path.absolutePath) {
OFString *currentDirectoryPath = [OFFileManager
defaultManager].currentDirectoryPath;
path = [currentDirectoryPath
stringByAppendingPathComponent: path];
path = path.stringByStandardizingPath;
}
path = [path
of_pathToURLPathWithURLEncodedHost: &URLEncodedHost];
_URLEncodedHost = [URLEncodedHost copy];
path = [path of_pathToURIPathWithPercentEncodedHost:
&percentEncodedHost];
_percentEncodedHost = [percentEncodedHost copy];
if (isDirectory && ![path hasSuffix: @"/"])
path = [path stringByAppendingString: @"/"];
_URLEncodedScheme = @"file";
_URLEncodedPath = [[path
stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLPathAllowedCharacterSet]] copy];
_percentEncodedScheme = @"file";
_percentEncodedPath = [[path
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIPathAllowedCharacterSet]] copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
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
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
|
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
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
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
|
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
+
-
+
-
-
+
|
objc_autoreleasePoolPop(pool);
return self;
}
- (void)dealloc
{
[_URLEncodedScheme release];
[_URLEncodedHost release];
[_percentEncodedScheme release];
[_percentEncodedHost release];
[_port release];
[_URLEncodedUser release];
[_URLEncodedPassword release];
[_URLEncodedPath release];
[_URLEncodedQuery release];
[_URLEncodedFragment release];
[_percentEncodedUser release];
[_percentEncodedPassword release];
[_percentEncodedPath release];
[_percentEncodedQuery release];
[_percentEncodedFragment release];
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFURL *URL;
OFURI *URI;
if (object == self)
return true;
if (![object isKindOfClass: [OFURL class]])
if (![object isKindOfClass: [OFURI class]])
return false;
URL = object;
URI = object;
if (URL->_URLEncodedScheme != _URLEncodedScheme &&
![URL->_URLEncodedScheme isEqual: _URLEncodedScheme])
if (URI->_percentEncodedScheme != _percentEncodedScheme &&
![URI->_percentEncodedScheme isEqual: _percentEncodedScheme])
return false;
if (URL->_URLEncodedHost != _URLEncodedHost &&
![URL->_URLEncodedHost isEqual: _URLEncodedHost])
if (URI->_percentEncodedHost != _percentEncodedHost &&
![URI->_percentEncodedHost isEqual: _percentEncodedHost])
return false;
if (URL->_port != _port && ![URL->_port isEqual: _port])
if (URI->_port != _port && ![URI->_port isEqual: _port])
return false;
if (URL->_URLEncodedUser != _URLEncodedUser &&
![URL->_URLEncodedUser isEqual: _URLEncodedUser])
if (URI->_percentEncodedUser != _percentEncodedUser &&
![URI->_percentEncodedUser isEqual: _percentEncodedUser])
return false;
if (URL->_URLEncodedPassword != _URLEncodedPassword &&
![URL->_URLEncodedPassword isEqual: _URLEncodedPassword])
if (URI->_percentEncodedPassword != _percentEncodedPassword &&
![URI->_percentEncodedPassword isEqual: _percentEncodedPassword])
return false;
if (URL->_URLEncodedPath != _URLEncodedPath &&
![URL->_URLEncodedPath isEqual: _URLEncodedPath])
if (URI->_percentEncodedPath != _percentEncodedPath &&
![URI->_percentEncodedPath isEqual: _percentEncodedPath])
return false;
if (URL->_URLEncodedQuery != _URLEncodedQuery &&
![URL->_URLEncodedQuery isEqual: _URLEncodedQuery])
if (URI->_percentEncodedQuery != _percentEncodedQuery &&
![URI->_percentEncodedQuery isEqual: _percentEncodedQuery])
return false;
if (URL->_URLEncodedFragment != _URLEncodedFragment &&
![URL->_URLEncodedFragment isEqual: _URLEncodedFragment])
if (URI->_percentEncodedFragment != _percentEncodedFragment &&
![URI->_percentEncodedFragment isEqual: _percentEncodedFragment])
return false;
return true;
}
- (unsigned long)hash
{
unsigned long hash;
OFHashInit(&hash);
OFHashAddHash(&hash, _URLEncodedScheme.hash);
OFHashAddHash(&hash, _URLEncodedHost.hash);
OFHashAddHash(&hash, _percentEncodedScheme.hash);
OFHashAddHash(&hash, _percentEncodedHost.hash);
OFHashAddHash(&hash, _port.hash);
OFHashAddHash(&hash, _URLEncodedUser.hash);
OFHashAddHash(&hash, _URLEncodedPassword.hash);
OFHashAddHash(&hash, _URLEncodedPath.hash);
OFHashAddHash(&hash, _URLEncodedQuery.hash);
OFHashAddHash(&hash, _URLEncodedFragment.hash);
OFHashAddHash(&hash, _percentEncodedUser.hash);
OFHashAddHash(&hash, _percentEncodedPassword.hash);
OFHashAddHash(&hash, _percentEncodedPath.hash);
OFHashAddHash(&hash, _percentEncodedQuery.hash);
OFHashAddHash(&hash, _percentEncodedFragment.hash);
OFHashFinalize(&hash);
return hash;
}
- (OFString *)scheme
{
return _URLEncodedScheme.stringByURLDecoding;
return _percentEncodedScheme.stringByRemovingPercentEncoding;
}
- (OFString *)URLEncodedScheme
- (OFString *)percentEncodedScheme
{
return _URLEncodedScheme;
return _percentEncodedScheme;
}
- (OFString *)host
{
if ([_URLEncodedHost hasPrefix: @"["] &&
[_URLEncodedHost hasSuffix: @"]"]) {
OFString *host = [_URLEncodedHost substringWithRange:
OFMakeRange(1, _URLEncodedHost.length - 2)];
if ([_percentEncodedHost hasPrefix: @"["] &&
[_percentEncodedHost hasSuffix: @"]"]) {
OFString *host = [_percentEncodedHost substringWithRange:
OFMakeRange(1, _percentEncodedHost.length - 2)];
if (!OFURLIsIPv6Host(host))
if (!OFURIIsIPv6Host(host))
@throw [OFInvalidArgumentException exception];
return host;
}
return _URLEncodedHost.stringByURLDecoding;
return _percentEncodedHost.stringByRemovingPercentEncoding;
}
- (OFString *)URLEncodedHost
- (OFString *)percentEncodedHost
{
return _URLEncodedHost;
return _percentEncodedHost;
}
- (OFNumber *)port
{
return _port;
}
- (OFString *)user
{
return _URLEncodedUser.stringByURLDecoding;
return _percentEncodedUser.stringByRemovingPercentEncoding;
}
- (OFString *)URLEncodedUser
- (OFString *)percentEncodedUser
{
return _URLEncodedUser;
return _percentEncodedUser;
}
- (OFString *)password
{
return _URLEncodedPassword.stringByURLDecoding;
return _percentEncodedPassword.stringByRemovingPercentEncoding;
}
- (OFString *)URLEncodedPassword
- (OFString *)percentEncodedPassword
{
return _URLEncodedPassword;
return _percentEncodedPassword;
}
- (OFString *)path
{
return _URLEncodedPath.stringByURLDecoding;
return _percentEncodedPath.stringByRemovingPercentEncoding;
}
- (OFString *)URLEncodedPath
- (OFString *)percentEncodedPath
{
return _URLEncodedPath;
return _percentEncodedPath;
}
- (OFArray *)pathComponents
{
void *pool = objc_autoreleasePoolPush();
#ifdef OF_HAVE_FILES
bool isFile = [_URLEncodedScheme isEqual: @"file"];
bool isFile = [_percentEncodedScheme isEqual: @"file"];
#endif
OFMutableArray *ret;
size_t count;
#ifdef OF_HAVE_FILES
if (isFile) {
OFString *path = [_URLEncodedPath
of_URLPathToPathWithURLEncodedHost: nil];
OFString *path = [_percentEncodedPath
of_URIPathToPathWithPercentEncodedHost: nil];
ret = [[path.pathComponents mutableCopy] autorelease];
if (![ret.firstObject isEqual: @"/"])
[ret insertObject: @"/" atIndex: 0];
} else
#endif
ret = [[[_URLEncodedPath componentsSeparatedByString: @"/"]
ret = [[[_percentEncodedPath componentsSeparatedByString: @"/"]
mutableCopy] autorelease];
count = ret.count;
if (count > 0 && [ret.firstObject length] == 0)
[ret replaceObjectAtIndex: 0 withObject: @"/"];
for (size_t i = 0; i < count; i++) {
OFString *component = [ret objectAtIndex: i];
#ifdef OF_HAVE_FILES
if (isFile)
component =
[component of_pathComponentToURLPathComponent];
[component of_pathComponentToURIPathComponent];
#endif
component = component.stringByRemovingPercentEncoding;
[ret replaceObjectAtIndex: i
[ret replaceObjectAtIndex: i withObject: component];
withObject: component.stringByURLDecoding];
}
[ret makeImmutable];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (OFString *)lastPathComponent
{
void *pool = objc_autoreleasePoolPush();
OFString *path = _URLEncodedPath;
OFString *path = _percentEncodedPath;
const char *UTF8String, *lastComponent;
size_t length;
OFString *ret;
if (path == nil) {
objc_autoreleasePoolPop(pool);
return nil;
|
︙ | | |
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
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
|
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
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
|
-
+
-
+
-
+
-
+
-
+
-
+
+
-
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
|
break;
}
}
ret = [OFString
stringWithUTF8String: lastComponent
length: length - (lastComponent - UTF8String)];
ret = [ret.stringByURLDecoding retain];
ret = [ret.stringByRemovingPercentEncoding retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (OFString *)query
{
return _URLEncodedQuery.stringByURLDecoding;
return _percentEncodedQuery.stringByRemovingPercentEncoding;
}
- (OFString *)URLEncodedQuery
- (OFString *)percentEncodedQuery
{
return _URLEncodedQuery;
return _percentEncodedQuery;
}
- (OFDictionary OF_GENERIC(OFString *, OFString *) *)queryDictionary
{
void *pool;
OFArray OF_GENERIC(OFString *) *pairs;
OFMutableDictionary OF_GENERIC(OFString *, OFString *) *ret;
if (_URLEncodedQuery == nil)
if (_percentEncodedQuery == nil)
return nil;
pool = objc_autoreleasePoolPush();
pairs = [_URLEncodedQuery componentsSeparatedByString: @"&"];
pairs = [_percentEncodedQuery componentsSeparatedByString: @"&"];
ret = [OFMutableDictionary dictionaryWithCapacity: pairs.count];
for (OFString *pair in pairs) {
OFArray *parts = [pair componentsSeparatedByString: @"="];
OFString *name, *value;
if (parts.count != 2)
@throw [OFInvalidFormatException exception];
[ret setObject: [[parts objectAtIndex: 1] stringByURLDecoding]
forKey: [[parts objectAtIndex: 0] stringByURLDecoding]];
name = [[parts objectAtIndex: 0]
stringByRemovingPercentEncoding];
value = [[parts objectAtIndex: 1]
stringByRemovingPercentEncoding];
[ret setObject: value forKey: name];
}
[ret makeImmutable];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (OFString *)fragment
{
return _URLEncodedFragment.stringByURLDecoding;
return _percentEncodedFragment.stringByRemovingPercentEncoding;
}
- (OFString *)URLEncodedFragment
- (OFString *)percentEncodedFragment
{
return _URLEncodedFragment;
return _percentEncodedFragment;
}
- (id)copy
{
return [self retain];
}
- (id)mutableCopy
{
OFURL *copy = [[OFMutableURL alloc] init];
OFURI *copy = [[OFMutableURI alloc] init];
@try {
copy->_URLEncodedScheme = [_URLEncodedScheme copy];
copy->_URLEncodedHost = [_URLEncodedHost copy];
copy->_percentEncodedScheme = [_percentEncodedScheme copy];
copy->_percentEncodedHost = [_percentEncodedHost copy];
copy->_port = [_port copy];
copy->_URLEncodedUser = [_URLEncodedUser copy];
copy->_URLEncodedPassword = [_URLEncodedPassword copy];
copy->_URLEncodedPath = [_URLEncodedPath copy];
copy->_URLEncodedQuery = [_URLEncodedQuery copy];
copy->_URLEncodedFragment = [_URLEncodedFragment copy];
copy->_percentEncodedUser = [_percentEncodedUser copy];
copy->_percentEncodedPassword = [_percentEncodedPassword copy];
copy->_percentEncodedPath = [_percentEncodedPath copy];
copy->_percentEncodedQuery = [_percentEncodedQuery copy];
copy->_percentEncodedFragment = [_percentEncodedFragment copy];
} @catch (id e) {
[copy release];
@throw e;
}
return copy;
}
- (OFString *)string
{
OFMutableString *ret = [OFMutableString string];
[ret appendFormat: @"%@://", _URLEncodedScheme];
[ret appendFormat: @"%@://", _percentEncodedScheme];
if (_URLEncodedUser != nil && _URLEncodedPassword != nil)
if (_percentEncodedUser != nil && _percentEncodedPassword != nil)
[ret appendFormat: @"%@:%@@",
_percentEncodedUser,
_URLEncodedUser, _URLEncodedPassword];
else if (_URLEncodedUser != nil)
[ret appendFormat: @"%@@", _URLEncodedUser];
_percentEncodedPassword];
else if (_percentEncodedUser != nil)
[ret appendFormat: @"%@@", _percentEncodedUser];
if (_URLEncodedHost != nil)
[ret appendString: _URLEncodedHost];
if (_percentEncodedHost != nil)
[ret appendString: _percentEncodedHost];
if (_port != nil)
[ret appendFormat: @":%@", _port];
if (_URLEncodedPath != nil) {
if (![_URLEncodedPath hasPrefix: @"/"])
if (_percentEncodedPath != nil) {
if (![_percentEncodedPath hasPrefix: @"/"])
@throw [OFInvalidFormatException exception];
[ret appendString: _URLEncodedPath];
[ret appendString: _percentEncodedPath];
}
if (_URLEncodedQuery != nil)
[ret appendFormat: @"?%@", _URLEncodedQuery];
if (_percentEncodedQuery != nil)
[ret appendFormat: @"?%@", _percentEncodedQuery];
if (_URLEncodedFragment != nil)
[ret appendFormat: @"#%@", _URLEncodedFragment];
if (_percentEncodedFragment != nil)
[ret appendFormat: @"#%@", _percentEncodedFragment];
[ret makeImmutable];
return ret;
}
#ifdef OF_HAVE_FILES
- (OFString *)fileSystemRepresentation
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
if (![_URLEncodedScheme isEqual: @"file"])
if (![_percentEncodedScheme isEqual: @"file"])
@throw [OFInvalidArgumentException exception];
if (![_URLEncodedPath hasPrefix: @"/"])
if (![_percentEncodedPath hasPrefix: @"/"])
@throw [OFInvalidFormatException exception];
path = [self.path of_URLPathToPathWithURLEncodedHost: _URLEncodedHost];
path = [self.path
of_URIPathToPathWithPercentEncodedHost: _percentEncodedHost];
[path retain];
objc_autoreleasePoolPop(pool);
return [path autorelease];
}
#endif
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
- (OFURI *)URIByAppendingPathComponent: (OFString *)component
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component];
[URL makeImmutable];
return URL;
OFMutableURI *URI = [[self mutableCopy] autorelease];
[URI appendPathComponent: component];
[URI makeImmutable];
return URI;
}
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
- (OFURI *)URIByAppendingPathComponent: (OFString *)component
isDirectory: (bool)isDirectory
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component isDirectory: isDirectory];
[URL makeImmutable];
return URL;
OFMutableURI *URI = [[self mutableCopy] autorelease];
[URI appendPathComponent: component isDirectory: isDirectory];
[URI makeImmutable];
return URI;
}
- (OFURL *)URLByStandardizingPath
- (OFURI *)URIByStandardizingPath
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL standardizePath];
[URL makeImmutable];
return URL;
OFMutableURI *URI = [[self mutableCopy] autorelease];
[URI standardizePath];
[URI makeImmutable];
return URI;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@>",
self.class, self.string];
}
|
︙ | | |
Renamed and modified
src/OFURLHandler.h
[2dde935dac]
to src/OFURIHandler.h
[bafac28b57].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFDate;
@class OFStream;
@class OFURL;
@class OFURI;
/**
* @class OFURLHandler OFURLHandler.h ObjFW/OFURLHandler.h
* @class OFURIHandler OFURIHandler.h ObjFW/OFURIHandler.h
*
* @brief A handler for a URL scheme.
* @brief A handler for a URI scheme.
*/
@interface OFURLHandler: OFObject
@interface OFURIHandler: OFObject
{
OFString *_scheme;
OF_RESERVE_IVARS(OFURLHandler, 4)
OF_RESERVE_IVARS(OFURIHandler, 4)
}
/**
* @brief The scheme this OFURLHandler handles.
* @brief The scheme this OFURIHandler handles.
*/
@property (readonly, nonatomic) OFString *scheme;
/**
* @brief Registers the specified class as the handler for the specified scheme.
*
* If the same class is specified for two schemes, one instance of it is
* created per scheme.
*
* @param class_ The class to register as the handler for the specified scheme
* @param scheme The scheme for which to register the handler
* @return Whether the class was successfully registered. If a handler for the
* same scheme is already registered, registration fails.
*/
+ (bool)registerClass: (Class)class_ forScheme: (OFString *)scheme;
/**
* @brief Returns the handler for the specified URL.
* @brief Returns the handler for the specified URI.
*
* @return The handler for the specified URL.
* @return The handler for the specified URI.
*/
+ (OFURLHandler *)handlerForURL: (OFURL *)URL;
+ (OFURIHandler *)handlerForURI: (OFURI *)URI;
/**
* @brief Opens the item at the specified URL.
* @brief Opens the item at the specified URI.
*
* @param URL The URL of the item which should be opened
* @param URI The URI 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.
* @return The opened stream if it was successfully opened
* @throw OFOpenItemFailedException Opening the item failed
*/
+ (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode;
+ (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes the handler for the specified scheme.
*
* @param scheme The scheme to initialize for
* @return An initialized URL handler
* @return An initialized URI handler
*/
- (instancetype)initWithScheme: (OFString *)scheme OF_DESIGNATED_INITIALIZER;
/**
* @brief Opens the item at the specified URL.
* @brief Opens the item at the specified URI.
*
* @param URL The URL of the item which should be opened
* @param URI The URI 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.
* @return The opened stream if it was successfully opened
* @throw OFOpenItemFailedException Opening the item failed
*/
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode;
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode;
/**
* @brief Returns the attributes for the item at the specified URL.
* @brief Returns the attributes for the item at the specified URI.
*
* @param URL The URL to return the attributes for
* @return A dictionary of attributes for the specified URL, with the keys of
* @param URI The URI to return the attributes for
* @return A dictionary of attributes for the specified URI, with the keys of
* type @ref OFFileAttributeKey
*/
- (OFFileAttributes)attributesOfItemAtURL: (OFURL *)URL;
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI;
/**
* @brief Sets the attributes for the item at the specified URL.
* @brief Sets the attributes for the item at the specified URI.
*
* All attributes not part of the dictionary are left unchanged.
*
* @param attributes The attributes to set for the specified URL
* @param URL The URL of the item to set the attributes for
* @param attributes The attributes to set for the specified URI
* @param URI The URI of the item to set the attributes for
*/
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURL: (OFURL *)URL;
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI;
/**
* @brief Checks whether a file exists at the specified URL.
* @brief Checks whether a file exists at the specified URI.
*
* @param URL The URL to check
* @return A boolean whether there is a file at the specified URL
* @param URI The URI to check
* @return A boolean whether there is a file at the specified URI
*/
- (bool)fileExistsAtURL: (OFURL *)URL;
- (bool)fileExistsAtURI: (OFURI *)URI;
/**
* @brief Checks whether a directory exists at the specified URL.
* @brief Checks whether a directory exists at the specified URI.
*
* @param URL The URL to check
* @return A boolean whether there is a directory at the specified URL
* @param URI The URI to check
* @return A boolean whether there is a directory at the specified URI
*/
- (bool)directoryExistsAtURL: (OFURL *)URL;
- (bool)directoryExistsAtURI: (OFURI *)URI;
/**
* @brief Creates a directory at the specified URL.
* @brief Creates a directory at the specified URI.
*
* @param URL The URL of the directory to create
* @param URI The URI of the directory to create
*/
- (void)createDirectoryAtURL: (OFURL *)URL;
- (void)createDirectoryAtURI: (OFURI *)URI;
/**
* @brief Returns an array with the URLs of the items in the specified
* @brief Returns an array with the URIs of the items in the specified
* directory.
*
* @note `.` and `..` are not part of the returned array.
*
* @param URL The URL to the directory whose items should be returned
* @return An array with the URLs of the items in the specified directory
* @param URI The URI to the directory whose items should be returned
* @return An array with the URIs of the items in the specified directory
*/
- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL;
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI;
/**
* @brief Removes the item at the specified URL.
* @brief Removes the item at the specified URI.
*
* If the item at the specified URL is a directory, it is removed recursively.
* If the item at the specified URI is a directory, it is removed recursively.
*
* @param URL The URL to the item which should be removed
* @param URI The URI to the item which should be removed
*/
- (void)removeItemAtURL: (OFURL *)URL;
- (void)removeItemAtURI: (OFURI *)URI;
/**
* @brief Creates a hard link for the specified item.
*
* The destination URL must have a full path, which means it must include the
* The destination URI must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URLs.
* This method is not available for all URIs.
*
* @param source The URL to the item for which a link should be created
* @param destination The URL to the item which should link to the source
* @param source The URI to the item for which a link should be created
* @param destination The URI to the item which should link to the source
*/
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination;
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
/**
* @brief Creates a symbolic link for an item.
*
* The destination uRL must have a full path, which means it must include the
* The destination URI must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URLs.
* This method is not available for all URIs.
*
* @note On Windows, this requires at least Windows Vista and administrator
* privileges!
*
* @param URL The URL to the item which should symbolically link to the target
* @param URI The URI to the item which should symbolically link to the target
* @param target The target of the symbolic link
*/
- (void)createSymbolicLinkAtURL: (OFURL *)URL
- (void)createSymbolicLinkAtURI: (OFURI *)URI
withDestinationPath: (OFString *)target;
/**
* @brief Tries to efficiently copy an item. If a copy would only be possible
* by reading the entire item and then writing it, it returns false.
*
* The destination URL must have a full path, which means it must include the
* The destination URI must have a full path, which means it must include the
* name of the item.
*
* If an item already exists, the copy operation fails. This is also the case
* if a directory is copied and an item already exists in the destination
* directory.
*
* @param source The file, directory or symbolic link to copy
* @param destination The destination URL
* @param destination The destination URI
* @return True if an efficient copy was performed, false if an efficient copy
* was not possible. Note that errors while performing a copy are
* reported via exceptions and not by returning false!
*/
- (bool)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination;
- (bool)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
/**
* @brief Tries to efficiently move an item. If a move would only be possible
* by copying the source and deleting it, it returns false.
*
* The destination URL must have a full path, which means it must include the
* The destination URI must have a full path, which means it must include the
* name of the item.
*
* If the destination is on a different logical device or uses a different
* scheme, an efficient move is not possible and false is returned.
*
* @param source The item to rename
* @param destination The new name for the item
* @return True if an efficient move was performed, false if an efficient move
* was not possible. Note that errors while performing a move are
* reported via exceptions and not by returning false!
*/
- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination;
- (bool)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFURLHandler.m
[b307a96ca2]
to src/OFURIHandler.m
[896717b5db].
︙ | | |
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFURLHandler.h"
#import "OFURIHandler.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFURL.h"
#import "OFURI.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
#import "OFEmbeddedFileURLHandler.h"
#import "OFEmbeddedURIHandler.h"
#ifdef OF_HAVE_FILES
# import "OFFileURLHandler.h"
# import "OFFileURIHandler.h"
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
# import "OFHTTPURLHandler.h"
# import "OFHTTPURIHandler.h"
#endif
#import "OFUnsupportedProtocolException.h"
static OFMutableDictionary OF_GENERIC(OFString *, OFURLHandler *) *handlers;
static OFMutableDictionary OF_GENERIC(OFString *, OFURIHandler *) *handlers;
#ifdef OF_HAVE_THREADS
static OFMutex *mutex;
static void
releaseMutex(void)
{
[mutex release];
}
#endif
@implementation OFURLHandler
@implementation OFURIHandler
@synthesize scheme = _scheme;
+ (void)initialize
{
if (self != [OFURLHandler class])
if (self != [OFURIHandler class])
return;
handlers = [[OFMutableDictionary alloc] init];
#ifdef OF_HAVE_THREADS
mutex = [[OFMutex alloc] init];
atexit(releaseMutex);
#endif
[self registerClass: [OFEmbeddedFileURLHandler class]
[self registerClass: [OFEmbeddedURIHandler class]
forScheme: @"objfw-embedded"];
#ifdef OF_HAVE_FILES
[self registerClass: [OFFileURLHandler class] forScheme: @"file"];
[self registerClass: [OFFileURIHandler class] forScheme: @"file"];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
[self registerClass: [OFHTTPURLHandler class] forScheme: @"http"];
[self registerClass: [OFHTTPURLHandler class] forScheme: @"https"];
[self registerClass: [OFHTTPURIHandler class] forScheme: @"http"];
[self registerClass: [OFHTTPURIHandler class] forScheme: @"https"];
#endif
}
+ (bool)registerClass: (Class)class forScheme: (OFString *)scheme
{
#ifdef OF_HAVE_THREADS
[mutex lock];
@try {
#endif
OFURLHandler *handler;
OFURIHandler *handler;
if ([handlers objectForKey: scheme] != nil)
return false;
handler = [[class alloc] initWithScheme: scheme];
@try {
[handlers setObject: handler forKey: scheme];
} @finally {
[handler release];
}
#ifdef OF_HAVE_THREADS
} @finally {
[mutex unlock];
}
#endif
return true;
}
+ (OFURLHandler *)handlerForURL: (OFURL *)URL
+ (OFURIHandler *)handlerForURI: (OFURI *)URI
{
OF_KINDOF(OFURLHandler *) handler;
OF_KINDOF(OFURIHandler *) handler;
#ifdef OF_HAVE_THREADS
[mutex lock];
@try {
#endif
handler = [handlers objectForKey: URL.scheme];
handler = [handlers objectForKey: URI.scheme];
#ifdef OF_HAVE_THREADS
} @finally {
[mutex unlock];
}
#endif
if (handler == nil)
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
return handler;
}
+ (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
+ (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
{
return [[self handlerForURL: URL] openItemAtURL: URL mode: mode];
return [[self handlerForURI: URI] openItemAtURI: URI mode: mode];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
- (void)dealloc
{
[_scheme release];
[super dealloc];
}
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFFileAttributes)attributesOfItemAtURL: (OFURL *)URL
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURL: (OFURL *)URL
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)fileExistsAtURL: (OFURL *)URL
- (bool)fileExistsAtURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)directoryExistsAtURL: (OFURL *)URL
- (bool)directoryExistsAtURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)createDirectoryAtURL: (OFURL *)URL
- (void)createDirectoryAtURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)removeItemAtURL: (OFURL *)URL
- (void)removeItemAtURI: (OFURI *)URI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)createSymbolicLinkAtURL: (OFURL *)destination
- (void)createSymbolicLinkAtURI: (OFURI *)destination
withDestinationPath: (OFString *)source
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (bool)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
return false;
}
- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination
- (bool)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination
{
return false;
}
@end
|
Modified src/OFZIPArchive.h
from [b2dd9ca588]
to [56eecfe29a].
︙ | | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
-
+
-
+
|
* @return A new, autoreleased OFZIPArchive
*/
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
/**
* @brief Creates a new OFZIPArchive object with the specified file.
*
* @param URL The URL to the ZIP file
* @param URI The URI to the ZIP file
* @param mode The mode for the ZIP file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return A new, autoreleased OFZIPArchive
*/
+ (instancetype)archiveWithURL: (OFURL *)URL mode: (OFString *)mode;
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFZIPArchive object with the
* specified stream.
*
|
︙ | | |
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
-
+
-
+
|
- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated OFZIPArchive object with the
* specified file.
*
* @param URL The URL to the ZIP file
* @param URI The URI to the ZIP file
* @param mode The mode for the ZIP file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return An initialized OFZIPArchive
*/
- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode;
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode;
/**
* @brief Returns a stream for reading the specified file from the archive.
*
* @note This method is only available in read mode.
*
* @note The returned stream conforms to @ref OFReadyForReadingObserving if the
|
︙ | | |
Modified src/OFZIPArchive.m
from [8085bc5ac7]
to [161538a2bd].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
|
#import "OFCRC32.h"
#import "OFData.h"
#import "OFDictionary.h"
#import "OFInflate64Stream.h"
#import "OFInflateStream.h"
#import "OFSeekableStream.h"
#import "OFStream.h"
#import "OFURLHandler.h"
#import "OFURIHandler.h"
#import "OFChecksumMismatchException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOpenItemFailedException.h"
|
︙ | | |
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
-
+
-
+
|
@synthesize archiveComment = _archiveComment;
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
}
+ (instancetype)archiveWithURL: (OFURL *)URL mode: (OFString *)mode
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode
{
return [[[self alloc] initWithURL: URL mode: mode] autorelease];
return [[[self alloc] initWithURI: URI mode: mode] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
-
+
-
+
-
+
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFStream *stream;
@try {
if ([mode isEqual: @"a"])
stream = [OFURLHandler openItemAtURL: URL mode: @"r+"];
stream = [OFURIHandler openItemAtURI: URI mode: @"r+"];
else
stream = [OFURLHandler openItemAtURL: URL mode: mode];
stream = [OFURIHandler openItemAtURI: URI mode: mode];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStream: stream mode: mode];
|
︙ | | |
Modified src/ObjFW.h
from [9fdc7f998d]
to [4cea05be8a].
︙ | | |
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
-
+
+
|
#import "OFMethodSignature.h"
#import "OFInvocation.h"
#import "OFNumber.h"
#import "OFDate.h"
#import "OFUUID.h"
#import "OFURL.h"
#import "OFURLHandler.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFColor.h"
#import "OFNotification.h"
#import "OFNotificationCenter.h"
#import "OFStream.h"
#import "OFSeekableStream.h"
|
︙ | | |
Modified src/exceptions/OFCopyItemFailedException.h
from [630315f2f6]
to [123bfde77a].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFCopyItemFailedException \
* OFCopyItemFailedException.h ObjFW/OFCopyItemFailedException.h
*
* @brief An exception indicating that copying a item failed.
*/
@interface OFCopyItemFailedException: OFException
{
OFURL *_sourceURL, *_destinationURL;
OFURI *_sourceURI, *_destinationURI;
int _errNo;
OF_RESERVE_IVARS(OFCopyItemFailedException, 4)
}
/**
* @brief The URL of the source item.
* @brief The URI of the source item.
*/
@property (readonly, nonatomic) OFURL *sourceURL;
@property (readonly, nonatomic) OFURI *sourceURI;
/**
* @brief The destination URL.
* @brief The destination URI.
*/
@property (readonly, nonatomic) OFURL *destinationURL;
@property (readonly, nonatomic) OFURI *destinationURI;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased copy item failed exception.
*
* @param sourceURL The URL of the source item
* @param destinationURL The destination URL
* @param sourceURI The URI of the source item
* @param destinationURI The destination URI
* @param errNo The errno of the error that occurred
* @return A new, autoreleased copy item failed exception
*/
+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
+ (instancetype)exceptionWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated copy item failed exception.
*
* @param sourceURL The URL of the source item
* @param destinationURL The destination URL
* @param sourceURI The URI of the source item
* @param destinationURI The destination URI
* @param errNo The errno of the error that occurred
* @return An initialized copy item failed exception
*/
- (instancetype)initWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
- (instancetype)initWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFCopyItemFailedException.m
from [db6f54b209]
to [86e24afee9].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
|
* file.
*/
#include "config.h"
#import "OFCopyItemFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFCopyItemFailedException
@synthesize sourceURL = _sourceURL, destinationURL = _destinationURL;
@synthesize sourceURI = _sourceURI, destinationURI = _destinationURI;
@synthesize errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
+ (instancetype)exceptionWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo
{
return [[[self alloc] initWithSourceURL: sourceURL
destinationURL: destinationURL
return [[[self alloc] initWithSourceURI: sourceURI
destinationURI: destinationURI
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
- (instancetype)initWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo
{
self = [super init];
@try {
_sourceURL = [sourceURL copy];
_destinationURL = [destinationURL copy];
_sourceURI = [sourceURI copy];
_destinationURI = [destinationURI copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_sourceURL release];
[_destinationURL release];
[_sourceURI release];
[_destinationURI release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat: @"Failed to copy item %@ to %@: %@",
_sourceURL, _destinationURL, OFStrError(_errNo)];
_sourceURI, _destinationURI, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFCreateDirectoryFailedException.h
from [f204a4e512]
to [e16c672401].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFCreateDirectoryFailedException \
* OFCreateDirectoryFailedException.h \
* ObjFW/OFCreateDirectoryFailedException.h
*
* @brief An exception indicating a directory couldn't be created.
*/
@interface OFCreateDirectoryFailedException: OFException
{
OFURL *_URL;
OFURI *_URI;
int _errNo;
OF_RESERVE_IVARS(OFCreateDirectoryFailedException, 4)
}
/**
* @brief The URL of the directory which couldn't be created.
* @brief The URI of the directory which couldn't be created.
*/
@property (readonly, nonatomic) OFURL *URL;
@property (readonly, nonatomic) OFURI *URI;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased create directory failed exception.
*
* @param URL The URL of the directory which could not be created
* @param URI The URI of the directory which could not be created
* @param errNo The errno of the error that occurred
* @return A new, autoreleased create directory failed exception
*/
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo;
+ (instancetype)exceptionWithURI: (OFURI *)URI errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated create directory failed exception.
*
* @param URL The URL of the directory which could not be created
* @param URI The URI of the directory which could not be created
* @param errNo The errno of the error that occurred
* @return An initialized create directory failed exception
*/
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFCreateDirectoryFailedException.m
from [c77cc11072]
to [cd0b53b912].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#include "config.h"
#import "OFCreateDirectoryFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFCreateDirectoryFailedException
@synthesize URL = _URL, errNo = _errNo;
@synthesize URI = _URI, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo
+ (instancetype)exceptionWithURI: (OFURI *)URI errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL errNo: errNo] autorelease];
return [[[self alloc] initWithURI: URI errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo
- (instancetype)initWithURI: (OFURI *)URI errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_URI = [URI copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_URL release];
[_URI release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to create directory %@: %@", _URL, OFStrError(_errNo)];
@"Failed to create directory %@: %@", _URI, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFCreateSymbolicLinkFailedException.h
from [200bfbec91]
to [79c2f6b7ee].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFCreateSymbolicLinkFailedException \
* OFCreateSymbolicLinkFailedException.h \
* ObjFW/OFCreateSymbolicLinkFailedException.h
*
* @brief An exception indicating that creating a symbolic link failed.
*/
@interface OFCreateSymbolicLinkFailedException: OFException
{
OFURL *_URL;
OFURI *_URI;
OFString *_target;
int _errNo;
OF_RESERVE_IVARS(OFCreateSymbolicLinkFailedException, 4)
}
/**
* @brief The URL at which the symlink should have been created.
* @brief The URI at which the symlink should have been created.
*/
@property (readonly, nonatomic) OFURL *URL;
@property (readonly, nonatomic) OFURI *URI;
/**
* @brief The target for the symlink.
*/
@property (readonly, nonatomic) OFString *target;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased create symbolic link failed exception.
*
* @param URL The URL where the symlink should have been created
* @param URI The URI where the symlink should have been created
* @param target The target for the symbolic link
* @param errNo The errno of the error that occurred
* @return A new, autoreleased create symbolic link failed exception
*/
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURI: (OFURI *)URI
target: (OFString *)target
errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated create symbolic link failed
* exception.
*
* @param URL The URL where the symlink should have been created
* @param URI The URI where the symlink should have been created
* @param target The target for the symbolic link
* @param errNo The errno of the error that occurred
* @return An initialized create symbolic link failed exception
*/
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
target: (OFString *)target
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFCreateSymbolicLinkFailedException.m
from [98cc87f63e]
to [c5e085b246].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#include "config.h"
#import "OFCreateSymbolicLinkFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFCreateSymbolicLinkFailedException
@synthesize URL = _URL, target = _target, errNo = _errNo;
@synthesize URI = _URI, target = _target, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURI: (OFURI *)URI
target: (OFString *)target
errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL
return [[[self alloc] initWithURI: URI
target: target
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
target: (OFString *)target
errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_URI = [URI copy];
_target = [target copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_URL release];
[_URI release];
[_target release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to create symbolic link %@ with target %@: %@",
_URL, _target, OFStrError(_errNo)];
_URI, _target, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFGetItemAttributesFailedException.h
from [08cb5169d1]
to [354af07fb2].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFGetItemAttributesFailedException \
* OFGetItemAttributesFailedException.h \
* ObjFW/OFGetItemAttributesFailedException.h
*
* @brief An exception indicating an item's attributes could not be retrieved.
*/
@interface OFGetItemAttributesFailedException: OFException
{
OFURL *_URL;
OFURI *_URI;
int _errNo;
OF_RESERVE_IVARS(OFGetItemAttributesFailedException, 4)
}
/**
* @brief The URL of the item whose attributes could not be retrieved.
* @brief The URI of the item whose attributes could not be retrieved.
*/
@property (readonly, nonatomic) OFURL *URL;
@property (readonly, nonatomic) OFURI *URI;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased retrieve item attributes failed exception.
*
* @param URL The URL of the item whose attributes could not be retrieved
* @param URI The URI of the item whose attributes could not be retrieved
* @param errNo The errno of the error that occurred
* @return A new, autoreleased retrieve item attributes failed exception
*/
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo;
+ (instancetype)exceptionWithURI: (OFURI *)URI errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated retrieve item attributes failed
* exception.
*
* @param URL The URL of the item whose attributes could not be retrieved
* @param URI The URI of the item whose attributes could not be retrieved
* @param errNo The errno of the error that occurred
* @return An initialized retrieve item attributes failed exception
*/
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFGetItemAttributesFailedException.m
from [2b7ee58368]
to [db212ce8f9].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#include "config.h"
#import "OFGetItemAttributesFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFGetItemAttributesFailedException
@synthesize URL = _URL, errNo = _errNo;
@synthesize URI = _URI, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo
+ (instancetype)exceptionWithURI: (OFURI *)URI errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL errNo: errNo] autorelease];
return [[[self alloc] initWithURI: URI errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo
- (instancetype)initWithURI: (OFURI *)URI errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_URI = [URI copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_URL release];
[_URI release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to get attributes for item %@: %@",
_URL, OFStrError(_errNo)];
_URI, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFHTTPRequestFailedException.m
from [02e986bf36]
to [f93ff97e23].
︙ | | |
60
61
62
63
64
65
66
67
68
69
70
|
60
61
62
63
64
65
66
67
68
69
70
|
-
-
+
+
|
}
- (OFString *)description
{
const char *method = OFHTTPRequestMethodName(_request.method);
return [OFString stringWithFormat:
@"An HTTP %s request with URL %@ failed with code %hd!", method,
_request.URL, _response.statusCode];
@"An HTTP %s request with URI %@ failed with code %hd!", method,
_request.URI, _response.statusCode];
}
@end
|
Modified src/exceptions/OFLinkItemFailedException.h
from [9e9934b885]
to [bc4e6321e5].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFLinkItemFailedException \
* OFLinkItemFailedException.h ObjFW/OFLinkItemFailedException.h
*
* @brief An exception indicating that creating a link failed.
*/
@interface OFLinkItemFailedException: OFException
{
OFURL *_sourceURL, *_destinationURL;
OFURI *_sourceURI, *_destinationURI;
int _errNo;
OF_RESERVE_IVARS(OFLinkItemFailedException, 4)
}
/**
* @brief A URL with the source for the link.
* @brief A URI with the source for the link.
*/
@property (readonly, nonatomic) OFURL *sourceURL;
@property (readonly, nonatomic) OFURI *sourceURI;
/**
* @brief A URL with the destination for the link.
* @brief A URI with the destination for the link.
*/
@property (readonly, nonatomic) OFURL *destinationURL;
@property (readonly, nonatomic) OFURI *destinationURI;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased link failed exception.
*
* @param sourceURL The source for the link
* @param destinationURL The destination for the link
* @param sourceURI The source for the link
* @param destinationURI The destination for the link
* @param errNo The errno of the error that occurred
* @return A new, autoreleased link failed exception
*/
+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
+ (instancetype)exceptionWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated link failed exception.
*
* @param sourceURL The source for the link
* @param destinationURL The destination for the link
* @param sourceURI The source for the link
* @param destinationURI The destination for the link
* @param errNo The errno of the error that occurred
* @return An initialized link failed exception
*/
- (instancetype)initWithSourceURL: (OFURL*)sourceURL
destinationURL: (OFURL *)destinationURL
- (instancetype)initWithSourceURI: (OFURI*)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFLinkItemFailedException.m
from [6a168f2101]
to [3033895110].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
|
* file.
*/
#include "config.h"
#import "OFLinkItemFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFLinkItemFailedException
@synthesize sourceURL = _sourceURL, destinationURL = _destinationURL;
@synthesize sourceURI = _sourceURI, destinationURI = _destinationURI;
@synthesize errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
+ (instancetype)exceptionWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo
{
return [[[self alloc] initWithSourceURL: sourceURL
destinationURL: destinationURL
return [[[self alloc] initWithSourceURI: sourceURI
destinationURI: destinationURI
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
- (instancetype)initWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo
{
self = [super init];
@try {
_sourceURL = [sourceURL copy];
_destinationURL = [destinationURL copy];
_sourceURI = [sourceURI copy];
_destinationURI = [destinationURI copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_sourceURL release];
[_destinationURL release];
[_sourceURI release];
[_destinationURI release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat: @"Failed to link file %@ to %@: %@",
_sourceURL, _destinationURL, OFStrError(_errNo)];
_sourceURI, _destinationURI, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFMoveItemFailedException.h
from [a67998f491]
to [f2cc0cdf02].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFMoveItemFailedException \
* OFMoveItemFailedException.h ObjFW/OFMoveItemFailedException.h
*
* @brief An exception indicating that moving an item failed.
*/
@interface OFMoveItemFailedException: OFException
{
OFURL *_sourceURL, *_destinationURL;
OFURI *_sourceURI, *_destinationURI;
int _errNo;
OF_RESERVE_IVARS(OFMoveItemFailedException, 4)
}
/**
* @brief The original URL.
* @brief The original URI.
*/
@property (readonly, nonatomic) OFURL *sourceURL;
@property (readonly, nonatomic) OFURI *sourceURI;
/**
* @brief The new URL.
* @brief The new URI.
*/
@property (readonly, nonatomic) OFURL *destinationURL;
@property (readonly, nonatomic) OFURI *destinationURI;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased move item failed exception.
*
* @param sourceURL The original URL
* @param destinationURL The new URL
* @param sourceURI The original URI
* @param destinationURI The new URI
* @param errNo The errno of the error that occurred
* @return A new, autoreleased move item failed exception
*/
+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
+ (instancetype)exceptionWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated move item failed exception.
*
* @param sourceURL The original URL
* @param destinationURL The new URL
* @param sourceURI The original URI
* @param destinationURI The new URI
* @param errNo The errno of the error that occurred
* @return An initialized move item failed exception
*/
- (instancetype)initWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
- (instancetype)initWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFMoveItemFailedException.m
from [4ea07cc8dd]
to [7df7241c06].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
|
* file.
*/
#include "config.h"
#import "OFMoveItemFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFMoveItemFailedException
@synthesize sourceURL = _sourceURL, destinationURL = _destinationURL;
@synthesize sourceURI = _sourceURI, destinationURI = _destinationURI;
@synthesize errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
+ (instancetype)exceptionWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo
{
return [[[self alloc] initWithSourceURL: sourceURL
destinationURL: destinationURL
return [[[self alloc] initWithSourceURI: sourceURI
destinationURI: destinationURI
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSourceURL: (OFURL *)sourceURL
destinationURL: (OFURL *)destinationURL
- (instancetype)initWithSourceURI: (OFURI *)sourceURI
destinationURI: (OFURI *)destinationURI
errNo: (int)errNo
{
self = [super init];
@try {
_sourceURL = [sourceURL copy];
_destinationURL = [destinationURL copy];
_sourceURI = [sourceURI copy];
_destinationURI = [destinationURI copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_sourceURL release];
[_destinationURL release];
[_sourceURI release];
[_destinationURI release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to move item at %@ to %@: %@",
_sourceURL, _destinationURL, OFStrError(_errNo)];
_sourceURI, _destinationURI, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFOpenItemFailedException.h
from [eff540d360]
to [fe988003bf].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
92
93
94
95
96
97
98
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
92
93
94
95
96
97
98
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFOpenItemFailedException \
* OFOpenItemFailedException.h ObjFW/OFOpenItemFailedException.h
*
* @brief An exception indicating an item could not be opened.
*/
@interface OFOpenItemFailedException: OFException
{
OFURL *_Nullable _URL;
OFURI *_Nullable _URI;
OFString *_Nullable _path;
OFString *_mode;
int _errNo;
OF_RESERVE_IVARS(OFOpenItemFailedException, 4)
}
/**
* @brief The URL of the item which could not be opened.
* @brief The URI of the item which could not be opened.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFURL *URL;
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFURI *URI;
/**
* @brief The path of the item which could not be opened.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path;
/**
* @brief The mode in which the item should have been opened.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *mode;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased open item failed exception.
*
* @param URL The URL of the item which could not be opened
* @param URI The URI of the item which could not be opened
* @param mode A string with the mode in which the item should have been opened
* @param errNo The errno of the error that occurred
* @return A new, autoreleased open item failed exception
*/
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURI: (OFURI *)URI
mode: (nullable OFString *)mode
errNo: (int)errNo;
/**
* @brief Creates a new, autoreleased open item failed exception.
*
* @param path The path of the item which could not be opened
* @param mode A string with the mode in which the item should have been opened
* @param errNo The errno of the error that occurred
* @return A new, autoreleased open item failed exception
*/
+ (instancetype)exceptionWithPath: (OFString *)path
mode: (nullable OFString *)mode
errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated open item failed exception.
*
* @param URL The URL of the item which could not be opened
* @param URI The URI of the item which could not be opened
* @param mode A string with the mode in which the item should have been opened
* @param errNo The errno of the error that occurred
* @return An initialized open item failed exception
*/
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
mode: (nullable OFString *)mode
errNo: (int)errNo;
/**
* @brief Initializes an already allocated open item failed exception.
*
* @param path The path of the item which could not be opened
|
︙ | | |
Modified src/exceptions/OFOpenItemFailedException.m
from [2b4ec7a8b3]
to [c620b20831].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#include "config.h"
#import "OFOpenItemFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFOpenItemFailedException
@synthesize URL = _URL, path = _path, mode = _mode, errNo = _errNo;
@synthesize URI = _URI, path = _path, mode = _mode, errNo = _errNo;
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURI: (OFURI *)URI
mode: (OFString *)mode
errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL
return [[[self alloc] initWithURI: URI
mode: mode
errNo: errNo] autorelease];
}
+ (instancetype)exceptionWithPath: (OFString *)path
mode: (OFString *)mode
errNo: (int)errNo
{
return [[[self alloc] initWithPath: path
mode: mode
errNo: errNo] autorelease];
}
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
mode: (OFString *)mode
errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_URI = [URI copy];
_mode = [mode copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
-
+
-
-
+
+
|
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_URL release];
[_URI release];
[_path release];
[_mode release];
[super dealloc];
}
- (OFString *)description
{
id item = nil;
if (_URL != nil)
item = _URL;
if (_URI != nil)
item = _URI;
else if (_path != nil)
item = _path;
if (_mode != nil)
return [OFString stringWithFormat:
@"Failed to open item %@ with mode %@: %@",
item, _mode, OFStrError(_errNo)];
else
return [OFString stringWithFormat:
@"Failed to open item %@: %@", item, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFRemoveItemFailedException.h
from [60915efe4d]
to [18b7b9ee6b].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFRemoveItemFailedException \
* OFRemoveItemFailedException.h ObjFW/OFRemoveItemFailedException.h
*
* @brief An exception indicating that removing an item failed.
*/
@interface OFRemoveItemFailedException: OFException
{
OFURL *_URL;
OFURI *_URI;
int _errNo;
OF_RESERVE_IVARS(OFRemoveItemFailedException, 4)
}
/**
* @brief The URL of the item which could not be removed.
* @brief The URI of the item which could not be removed.
*/
@property (readonly, nonatomic) OFURL *URL;
@property (readonly, nonatomic) OFURI *URI;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief Creates a new, autoreleased remove failed exception.
*
* @param URL The URL of the item which could not be removed
* @param URI The URI of the item which could not be removed
* @param errNo The errno of the error that occurred
* @return A new, autoreleased remove item failed exception
*/
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo;
+ (instancetype)exceptionWithURI: (OFURI *)URI errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated remove failed exception.
*
* @param URL The URL of the item which could not be removed
* @param URI The URI of the item which could not be removed
* @param errNo The errno of the error that occurred
* @return An initialized remove item failed exception
*/
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFRemoveItemFailedException.m
from [be28f37327]
to [790fd92540].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#include "config.h"
#import "OFRemoveItemFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFRemoveItemFailedException
@synthesize URL = _URL, errNo = _errNo;
@synthesize URI = _URI, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo
+ (instancetype)exceptionWithURI: (OFURI *)URI errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL errNo: errNo] autorelease];
return [[[self alloc] initWithURI: URI errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo
- (instancetype)initWithURI: (OFURI *)URI errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_URI = [URI copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_URL release];
[_URI release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to remove item at URL %@: %@", _URL, OFStrError(_errNo)];
@"Failed to remove item at URI %@: %@", _URI, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFSetItemAttributesFailedException.h
from [8ece988d41]
to [4b245f8a54].
︙ | | |
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
92
93
94
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
92
93
94
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
#import "OFURLHandler.h"
#import "OFURIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFSetItemAttributesFailedException \
* OFSetItemAttributesFailedException.h \
* ObjFW/OFSetItemAttributesFailedException.h
*
* @brief An exception indicating an item's attributes could not be set.
*/
@interface OFSetItemAttributesFailedException: OFException
{
OFURL *_URL;
OFURI *_URI;
OFFileAttributes _attributes;
OFFileAttributeKey _failedAttribute;
int _errNo;
OF_RESERVE_IVARS(OFSetItemAttributesFailedException, 4)
}
/**
* @brief The URL of the item whose attributes could not be set.
* @brief The URI of the item whose attributes could not be set.
*/
@property (readonly, nonatomic) OFURL *URL;
@property (readonly, nonatomic) OFURI *URI;
/**
* @brief The errno of the error that occurred.
*/
@property (readonly, nonatomic) int errNo;
/**
* @brief The attributes that should have been set.
*/
@property (readonly, nonatomic) OFFileAttributes attributes;
/**
* @brief The first attribute that could not be set.
*/
@property (readonly, nonatomic) OFFileAttributeKey failedAttribute;
/**
* @brief Creates a new, autoreleased set item attributes failed exception.
*
* @param URL The URL of the item whose attributes could not be set
* @param URI The URI of the item whose attributes could not be set
* @param attributes The attributes that should have been set for the specified
* item.
* @param failedAttribute The first attribute that could not be set
* @param errNo The errno of the error that occurred
* @return A new, autoreleased set item attributes failed exception
*/
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURI: (OFURI *)URI
attributes: (OFFileAttributes)attributes
failedAttribute: (OFFileAttributeKey)failedAttribute
errNo: (int)errNo;
+ (instancetype)exception OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated set item attributes failed exception.
*
* @param URL The URL of the item whose attributes could not be set
* @param URI The URI of the item whose attributes could not be set
* @param attributes The attributes that should have been set for the specified
* item.
* @param failedAttribute The first attribute that could not be set
* @param errNo The errno of the error that occurred
* @return An initialized set item attributes failed exception
*/
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
attributes: (OFFileAttributes)attributes
failedAttribute: (OFFileAttributeKey)failedAttribute
errNo: (int)errNo OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFSetItemAttributesFailedException.m
from [c7f09ee0c0]
to [419b3c1aff].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#include "config.h"
#import "OFSetItemAttributesFailedException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFSetItemAttributesFailedException
@synthesize URL = _URL, attributes = _attributes;
@synthesize URI = _URI, attributes = _attributes;
@synthesize failedAttribute = _failedAttribute, errNo = _errNo;
+ (instancetype)exception
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURI: (OFURI *)URI
attributes: (OFFileAttributes)attributes
failedAttribute: (OFFileAttributeKey)failedAttribute
errNo: (int)errNo
{
return [[[self alloc] initWithURL: URL
return [[[self alloc] initWithURI: URI
attributes: attributes
failedAttribute: failedAttribute
errNo: errNo] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
attributes: (OFFileAttributes)attributes
failedAttribute: (OFFileAttributeKey)failedAttribute
errNo: (int)errNo
{
self = [super init];
@try {
_URL = [URL copy];
_URI = [URI copy];
_attributes = [attributes copy];
_failedAttribute = [failedAttribute copy];
_errNo = errNo;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_URL release];
[_URI release];
[_attributes release];
[_failedAttribute release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to set attribute %@ for item %@: %@",
_failedAttribute, _URL, OFStrError(_errNo)];
_failedAttribute, _URI, OFStrError(_errNo)];
}
@end
|
Modified src/exceptions/OFUnsupportedProtocolException.h
from [2e727d85fe]
to [229fefef5c].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#import "OFException.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURL;
@class OFURI;
/**
* @class OFUnsupportedProtocolException \
* OFUnsupportedProtocolException.h \
* ObjFW/OFUnsupportedProtocolException.h
*
* @brief An exception indicating that the protocol specified by the URL is not
* @brief An exception indicating that the protocol specified by the URI is not
* supported.
*/
@interface OFUnsupportedProtocolException: OFException
{
OFURL *_Nullable _URL;
OFURI *_Nullable _URI;
OF_RESERVE_IVARS(OFUnsupportedProtocolException, 4)
}
/**
* @brief The URL whose protocol is unsupported.
* @brief The URI whose protocol is unsupported.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFURL *URL;
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFURI *URI;
/**
* @brief Creates a new, autoreleased unsupported protocol exception.
*
* @param URL The URL whose protocol is unsupported
* @param URI The URI whose protocol is unsupported
* @return A new, autoreleased unsupported protocol exception
*/
+ (instancetype)exceptionWithURL: (nullable OFURL*)URL;
+ (instancetype)exceptionWithURI: (nullable OFURI*)URI;
/**
* @brief Initializes an already allocated unsupported protocol exception
*
* @param URL The URL whose protocol is unsupported
* @param URI The URI whose protocol is unsupported
* @return An initialized unsupported protocol exception
*/
- (instancetype)initWithURL: (nullable OFURL*)URL OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithURI: (nullable OFURI*)URI OF_DESIGNATED_INITIALIZER;
@end
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFUnsupportedProtocolException.m
from [ba097adb5e]
to [a391485837].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* file.
*/
#include "config.h"
#import "OFUnsupportedProtocolException.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFURI.h"
@implementation OFUnsupportedProtocolException
@synthesize URL = _URL;
@synthesize URI = _URI;
+ (instancetype)exceptionWithURL: (OFURL *)URL
+ (instancetype)exceptionWithURI: (OFURI *)URI
{
return [[[self alloc] initWithURL: URL] autorelease];
return [[[self alloc] initWithURI: URI] autorelease];
}
- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURI: (OFURI *)URI
{
self = [super init];
_URL = [URL retain];
_URI = [URI retain];
return self;
}
- (void)dealloc
{
[_URL release];
[_URI release];
[super dealloc];
}
- (OFString *)description
{
if (_URL != nil)
if (_URI != nil)
return [OFString stringWithFormat:
@"The protocol of URL %@ is not supported!", _URL];
@"The protocol of URI %@ is not supported!", _URI];
else
return @"The requested protocol is unsupported!";
}
@end
|
Modified src/platform/AmigaOS/OFString+PathAdditions.m
from [5c5c7fbd79]
to [60752aa5d1].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
+
|
* file.
*/
#include "config.h"
#import "OFString+PathAdditions.h"
#import "OFArray.h"
#import "OFFileURLHandler.h"
#import "OFFileURIHandler.h"
#import "OFOutOfRangeException.h"
int _OFString_PathAdditions_reference;
@implementation OFString (PathAdditions)
+ (OFString *)pathWithComponents: (OFArray *)components
|
︙ | | |
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
-
+
-
+
+
|
} else
return [self stringByAppendingFormat: @".%@", extension];
}
- (bool)of_isDirectoryPath
{
return ([self hasSuffix: @"/"] || [self hasSuffix: @":"] ||
[OFFileURLHandler of_directoryExistsAtPath: self]);
[OFFileURIHandler of_directoryExistsAtPath: self]);
}
- (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost
- (OFString *)of_pathToURIPathWithPercentEncodedHost:
(OFString **)percentEncodedHost
{
OFArray OF_GENERIC(OFString *) *components = self.pathComponents;
OFMutableString *ret = [OFMutableString string];
for (OFString *component in components) {
if (component.length == 0)
continue;
|
︙ | | |
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
-
+
+
|
}
[ret makeImmutable];
return ret;
}
- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost
- (OFString *)of_URIPathToPathWithPercentEncodedHost:
(OFString *)percentEncodedHost
{
OFString *path = self;
if (path.length > 1 && [path hasSuffix: @"/"])
path = [path substringToIndex: path.length - 1];
OFMutableArray OF_GENERIC(OFString *) *components;
|
︙ | | |
347
348
349
350
351
352
353
354
355
356
357
358
|
349
350
351
352
353
354
355
356
357
358
359
360
|
-
+
|
if ([component isEqual: @".."])
[components replaceObjectAtIndex: i withObject: @"/"];
}
return [OFString pathWithComponents: components];
}
- (OFString *)of_pathComponentToURLPathComponent
- (OFString *)of_pathComponentToURIPathComponent
{
return self;
}
@end
|
Modified src/platform/POSIX/OFString+PathAdditions.m
from [36c0dee2bc]
to [d1f51523cf].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
+
|
* file.
*/
#include "config.h"
#import "OFString+PathAdditions.h"
#import "OFArray.h"
#import "OFFileURLHandler.h"
#import "OFFileURIHandler.h"
#import "OFOutOfRangeException.h"
int _OFString_PathAdditions_reference;
@implementation OFString (PathAdditions)
+ (OFString *)pathWithComponents: (OFArray *)components
|
︙ | | |
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
-
+
-
+
+
-
+
+
-
+
|
} else
return [self stringByAppendingFormat: @".%@", extension];
}
- (bool)of_isDirectoryPath
{
return ([self hasSuffix: @"/"] ||
[OFFileURLHandler of_directoryExistsAtPath: self]);
[OFFileURIHandler of_directoryExistsAtPath: self]);
}
- (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost
- (OFString *)of_pathToURIPathWithPercentEncodedHost:
(OFString **)percentEncodedHost
{
return self;
}
- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost
- (OFString *)of_URIPathToPathWithPercentEncodedHost:
(OFString *)percentEncodedHost
{
OFString *path = self;
if (path.length > 1 && [path hasSuffix: @"/"])
path = [path substringToIndex: path.length - 1];
return path;
}
- (OFString *)of_pathComponentToURLPathComponent
- (OFString *)of_pathComponentToURIPathComponent
{
return self;
}
@end
|
Modified src/platform/Windows/OFString+PathAdditions.m
from [f4b6d7c22e]
to [ec08b34f89].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
-
+
+
|
* Windows-specific parts!
*/
#include "config.h"
#import "OFString+PathAdditions.h"
#import "OFArray.h"
#import "OFFileURLHandler.h"
#import "OFURL.h"
#import "OFFileURIHandler.h"
#import "OFURI.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
int _OFString_PathAdditions_reference;
@implementation OFString (PathAdditions)
|
︙ | | |
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
-
+
-
+
+
-
-
-
+
+
+
-
+
+
-
-
+
+
+
-
+
|
} else
return [self stringByAppendingFormat: @".%@", extension];
}
- (bool)of_isDirectoryPath
{
return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] ||
[OFFileURLHandler of_directoryExistsAtPath: self]);
[OFFileURIHandler of_directoryExistsAtPath: self]);
}
- (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost
- (OFString *)of_pathToURIPathWithPercentEncodedHost:
(OFString **)percentEncodedHost
{
OFString *path = self;
if ([path hasPrefix: @"\\\\"]) {
OFArray *components = path.pathComponents;
if (components.count < 2)
@throw [OFInvalidFormatException exception];
*URLEncodedHost = [[components objectAtIndex: 1]
stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLHostAllowedCharacterSet]];
*percentEncodedHost = [[components objectAtIndex: 1]
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIHostAllowedCharacterSet]];
path = [OFString pathWithComponents: [components
objectsInRange: OFMakeRange(2, components.count - 2)]];
}
path = [path stringByReplacingOccurrencesOfString: @"\\"
withString: @"/"];
path = [@"/" stringByAppendingString: path];
return path;
}
- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost
- (OFString *)of_URIPathToPathWithPercentEncodedHost:
(OFString *)percentEncodedHost
{
OFString *path = self;
if (path.length > 1 && [path hasSuffix: @"/"] &&
![path hasSuffix: @":/"])
path = [path substringToIndex: path.length - 1];
path = [path substringFromIndex: 1];
path = [path stringByReplacingOccurrencesOfString: @"/"
withString: @"\\"];
if (URLEncodedHost != nil) {
OFString *host = [URLEncodedHost stringByURLDecoding];
if (percentEncodedHost != nil) {
OFString *host = [percentEncodedHost
stringByRemovingPercentEncoding];
if (path.length == 0)
path = [OFString stringWithFormat: @"\\\\%@", host];
else
path = [OFString stringWithFormat: @"\\\\%@\\%@",
host, path];
}
return path;
}
- (OFString *)of_pathComponentToURLPathComponent
- (OFString *)of_pathComponentToURIPathComponent
{
return [self stringByReplacingOccurrencesOfString: @"\\"
withString: @"/"];
}
@end
|
Modified src/platform/libfat/OFString+PathAdditions.m
from [7b438d1726]
to [6647377f7a].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
+
|
* file.
*/
#include "config.h"
#import "OFString+PathAdditions.h"
#import "OFArray.h"
#import "OFFileURLHandler.h"
#import "OFFileURIHandler.h"
#import "OFOutOfRangeException.h"
int _OFString_PathAdditions_reference;
@implementation OFString (PathAdditions)
+ (OFString *)pathWithComponents: (OFArray *)components
|
︙ | | |
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
-
+
-
+
+
-
+
+
-
+
|
} else
return [self stringByAppendingFormat: @".%@", extension];
}
- (bool)of_isDirectoryPath
{
return ([self hasSuffix: @"/"] ||
[OFFileURLHandler of_directoryExistsAtPath: self]);
[OFFileURIHandler of_directoryExistsAtPath: self]);
}
- (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost
- (OFString *)of_pathToURIPathWithPercentEncodedHost:
(OFString **)percentEncodedHost
{
return [@"/" stringByAppendingString: self];
}
- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost
- (OFString *)of_URIPathToPathWithPercentEncodedHost:
(OFString *)percentEncodedHost
{
OFString *path = self;
if (path.length > 1 && [path hasSuffix: @"/"])
path = [path substringToIndex: path.length - 1];
return [path substringFromIndex: 1];
}
- (OFString *)of_pathComponentToURLPathComponent
- (OFString *)of_pathComponentToURIPathComponent
{
return self;
}
@end
|
Modified tests/Makefile
from [798d177ea8]
to [4d4716309a].
︙ | | |
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
-
+
|
OFSHA512HashTests.m \
OFScryptTests.m \
OFSerializationTests.m \
OFSetTests.m \
OFStreamTests.m \
OFStringTests.m \
OFSystemInfoTests.m \
OFURLTests.m \
OFURITests.m \
OFValueTests.m \
OFXMLElementBuilderTests.m \
OFXMLNodeTests.m \
OFXMLParserTests.m \
RuntimeTests.m \
${RUNTIME_ARC_TESTS_M} \
TestsAppDelegate.m \
|
︙ | | |
Modified tests/OFArrayTests.m
from [80326b9933]
to [cc2ce2f7d0].
︙ | | |
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
-
-
-
+
+
+
-
-
-
+
+
+
|
valueForKey: @"length"] isEqual:
[arrayClass arrayWithObjects: [OFNumber numberWithInt: 3],
[OFNumber numberWithInt: 3], [OFNumber numberWithInt: 6], nil]] &&
[[[arrayClass arrayWithObjects: @"1", @"2", nil]
valueForKey: @"@count"] isEqual: [OFNumber numberWithInt: 2]])
mutableArray1 = [mutableArrayClass arrayWithObjects:
[OFMutableURL URLWithString: @"http://foo.bar/"],
[OFMutableURL URLWithString: @"http://bar.qux/"],
[OFMutableURL URLWithString: @"http://qux.quxqux/"], nil];
[OFMutableURI URIWithString: @"http://foo.bar/"],
[OFMutableURI URIWithString: @"http://bar.qux/"],
[OFMutableURI URIWithString: @"http://qux.quxqux/"], nil];
TEST(@"-[setValue:forKey:]",
R([mutableArray1 setValue: [OFNumber numberWithShort: 1234]
forKey: @"port"]) &&
[mutableArray1 isEqual: [arrayClass arrayWithObjects:
[OFURL URLWithString: @"http://foo.bar:1234/"],
[OFURL URLWithString: @"http://bar.qux:1234/"],
[OFURL URLWithString: @"http://qux.quxqux:1234/"], nil]])
[OFURI URIWithString: @"http://foo.bar:1234/"],
[OFURI URIWithString: @"http://bar.qux:1234/"],
[OFURI URIWithString: @"http://qux.quxqux:1234/"], nil]])
objc_autoreleasePoolPop(pool);
}
- (void)arrayTests
{
module = @"OFArray";
|
︙ | | |
Modified tests/OFDictionaryTests.m
from [7127a0734c]
to [c3ff6abd22].
︙ | | |
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
-
+
-
+
|
ok = true;
}
TEST(@"Detection of mutation during Fast Enumeration", ok)
[mutableDict removeObjectForKey: @""];
TEST(@"-[stringByURLEncoding]",
TEST(@"-[URIQueryString]",
[[[OFDictionary dictionaryWithKeysAndObjects: @"foo", @"bar",
@"q&x", @"q=x", nil]
stringByURLEncoding] isEqual: @"q%26x=q%3Dx&foo=bar"])
URIQueryString] isEqual: @"q%26x=q%3Dx&foo=bar"])
#ifdef OF_HAVE_BLOCKS
{
__block size_t j = 0;
__block bool blockOk = true;
[mutableDict enumerateKeysAndObjectsUsingBlock:
|
︙ | | |
Modified tests/OFHMACTests.m
from [38283dce16]
to [b37a3e3b24].
︙ | | |
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
-
-
+
+
|
"\x61\xB3\xF9\x1A\xE3\x09\x43\xA6\x5B\x85\xB1\x50\x5B\xCB\x1A\x2E"
"\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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI 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/OFHTTPClientTests.m
from [0615ead311]
to [64ad652a21].
︙ | | |
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
131
132
|
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
131
132
|
-
+
-
+
-
+
|
[[OFRunLoop mainRunLoop] stop];
}
- (void)HTTPClientTests
{
void *pool = objc_autoreleasePoolPush();
HTTPClientTestsServer *server;
OFURL *URL;
OFURI *URI;
OFHTTPClient *client;
OFHTTPRequest *request;
OFData *data;
condition = [OFCondition condition];
[condition lock];
server = [[[HTTPClientTestsServer alloc] init] autorelease];
server.supportsSockets = true;
[server start];
[condition wait];
[condition unlock];
URL = [OFURL URLWithString:
URI = [OFURI URIWithString:
[OFString stringWithFormat: @"http://127.0.0.1:%" @PRIu16 "/foo",
server->_port]];
TEST(@"-[asyncPerformRequest:]",
(client = [OFHTTPClient client]) && (client.delegate = self) &&
(request = [OFHTTPRequest requestWithURL: URL]) &&
(request = [OFHTTPRequest requestWithURI: URI]) &&
(request.headers =
[OFDictionary dictionaryWithObject: @"5"
forKey: @"Content-Length"]) &&
R([client asyncPerformRequest: request]))
[[OFRunLoop mainRunLoop] runUntilDate:
[OFDate dateWithTimeIntervalSinceNow: 2]];
|
︙ | | |
Modified tests/OFHTTPCookieManagerTests.m
from [8647894d6b]
to [fc980e6e00].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
92
93
94
95
96
97
98
99
100
101
102
103
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
92
93
94
95
96
97
98
99
100
101
102
103
|
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
|
static OFString *const module = @"OFHTTPCookieManager";
@implementation TestsAppDelegate (OFHTTPCookieManagerTests)
- (void)HTTPCookieManagerTests
{
void *pool = objc_autoreleasePoolPush();
OFHTTPCookieManager *manager = [OFHTTPCookieManager manager];
OFURL *URL1, *URL2, *URL3, *URL4;
OFURI *URI1, *URI2, *URI3, *URI4;
OFHTTPCookie *cookie1, *cookie2, *cookie3, *cookie4, *cookie5;
URL1 = [OFURL URLWithString: @"http://nil.im/foo"];
URL2 = [OFURL URLWithString: @"https://nil.im/foo/bar"];
URL3 = [OFURL URLWithString: @"https://test.nil.im/foo/bar"];
URL4 = [OFURL URLWithString: @"http://webkeks.org/foo/bar"];
URI1 = [OFURI URIWithString: @"http://nil.im/foo"];
URI2 = [OFURI URIWithString: @"https://nil.im/foo/bar"];
URI3 = [OFURI URIWithString: @"https://test.nil.im/foo/bar"];
URI4 = [OFURI URIWithString: @"http://webkeks.org/foo/bar"];
cookie1 = [OFHTTPCookie cookieWithName: @"test"
value: @"1"
domain: @"nil.im"];
TEST(@"-[addCookie:forURL:] #1",
R([manager addCookie: cookie1 forURL: URL1]))
TEST(@"-[addCookie:forURI:] #1",
R([manager addCookie: cookie1 forURI: URI1]))
TEST(@"-[cookiesForURL:] #1",
[[manager cookiesForURL: URL1] isEqual:
TEST(@"-[cookiesForURI:] #1",
[[manager cookiesForURI: URI1] isEqual:
[OFArray arrayWithObject: cookie1]])
cookie2 = [OFHTTPCookie cookieWithName: @"test"
value: @"2"
domain: @"webkeks.org"];
TEST(@"-[addCookie:forURL:] #2",
R([manager addCookie: cookie2 forURL: URL1]))
TEST(@"-[addCookie:forURI:] #2",
R([manager addCookie: cookie2 forURI: URI1]))
TEST(@"-[cookiesForURL:] #2",
[[manager cookiesForURL: URL1] isEqual:
TEST(@"-[cookiesForURI:] #2",
[[manager cookiesForURI: URI1] isEqual:
[OFArray arrayWithObject: cookie1]] &&
[[manager cookiesForURL: URL4] isEqual: [OFArray array]])
[[manager cookiesForURI: URI4] isEqual: [OFArray array]])
cookie3 = [OFHTTPCookie cookieWithName: @"test"
value: @"3"
domain: @"nil.im"];
cookie3.secure = true;
TEST(@"-[addCookie:forURL:] #3",
R([manager addCookie: cookie3 forURL: URL2]))
TEST(@"-[addCookie:forURI:] #3",
R([manager addCookie: cookie3 forURI: URI2]))
TEST(@"-[cookiesForURL:] #3",
[[manager cookiesForURL: URL2] isEqual:
TEST(@"-[cookiesForURI:] #3",
[[manager cookiesForURI: URI2] isEqual:
[OFArray arrayWithObject: cookie3]] &&
[[manager cookiesForURL: URL1] isEqual: [OFArray array]])
[[manager cookiesForURI: URI1] isEqual: [OFArray array]])
cookie3.expires = [OFDate dateWithTimeIntervalSinceNow: -1];
cookie4 = [OFHTTPCookie cookieWithName: @"test"
value: @"4"
domain: @"nil.im"];
cookie4.domain = @".nil.im";
TEST(@"-[addCookie:forURL:] #4",
R([manager addCookie: cookie4 forURL: URL2]))
TEST(@"-[addCookie:forURI:] #4",
R([manager addCookie: cookie4 forURI: URI2]))
TEST(@"-[cookiesForURL:] #4",
[[manager cookiesForURL: URL2] isEqual:
TEST(@"-[cookiesForURI:] #4",
[[manager cookiesForURI: URI2] isEqual:
[OFArray arrayWithObject: cookie4]] &&
[[manager cookiesForURL: URL3] isEqual:
[[manager cookiesForURI: URI3] isEqual:
[OFArray arrayWithObject: cookie4]])
cookie5 = [OFHTTPCookie cookieWithName: @"bar"
value: @"5"
domain: @"test.nil.im"];
TEST(@"-[addCookie:forURL:] #5",
R([manager addCookie: cookie5 forURL: URL1]))
TEST(@"-[addCookie:forURI:] #5",
R([manager addCookie: cookie5 forURI: URI1]))
TEST(@"-[cookiesForURL:] #5",
[[manager cookiesForURL: URL1] isEqual:
TEST(@"-[cookiesForURI:] #5",
[[manager cookiesForURI: URI1] isEqual:
[OFArray arrayWithObject: cookie4]] &&
[[manager cookiesForURL: URL3] isEqual:
[[manager cookiesForURI: URI3] isEqual:
[OFArray arrayWithObjects: cookie4, cookie5, nil]])
TEST(@"-[purgeExpiredCookies]",
[manager.cookies isEqual:
[OFArray arrayWithObjects: cookie3, cookie4, cookie5, nil]] &&
R([manager purgeExpiredCookies]) &&
[manager.cookies isEqual:
[OFArray arrayWithObjects: cookie4, cookie5, nil]])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFHTTPCookieTests.m
from [e2e55e8f73]
to [beb8a32ced].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
static OFString *const module = @"OFHTTPCookie";
@implementation TestsAppDelegate (OFHTTPCookieTests)
- (void)HTTPCookieTests
{
void *pool = objc_autoreleasePoolPush();
OFURL *URL = [OFURL URLWithString: @"http://nil.im"];
OFURI *URI = [OFURI URIWithString: @"http://nil.im"];
OFHTTPCookie *cookie1, *cookie2;
OFArray OF_GENERIC(OFHTTPCookie *) *cookies;
cookie1 = [OFHTTPCookie cookieWithName: @"foo"
value: @"bar"
domain: @"nil.im"];
TEST(@"+[cookiesWithResponseHeaderFields:forURL:] #1",
TEST(@"+[cookiesWithResponseHeaderFields:forURI:] #1",
[[OFHTTPCookie cookiesWithResponseHeaderFields: [OFDictionary
dictionaryWithObject: @"foo=bar"
forKey: @"Set-Cookie"] forURL: URL]
forKey: @"Set-Cookie"] forURI: URI]
isEqual: [OFArray arrayWithObject: cookie1]])
cookie2 = [OFHTTPCookie cookieWithName: @"qux"
value: @"cookie"
domain: @"nil.im"];
TEST(@"+[cookiesWithResponseHeaderFields:forURL:] #2",
TEST(@"+[cookiesWithResponseHeaderFields:forURI:] #2",
[[OFHTTPCookie cookiesWithResponseHeaderFields: [OFDictionary
dictionaryWithObject: @"foo=bar,qux=cookie"
forKey: @"Set-Cookie"] forURL: URL]
forKey: @"Set-Cookie"] forURI: URI]
isEqual: [OFArray arrayWithObjects: cookie1, cookie2, nil]])
cookie1.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890];
cookie2.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890];
cookie1.path = @"/x";
cookie2.domain = @"webkeks.org";
cookie2.path = @"/objfw";
cookie2.secure = true;
cookie2.HTTPOnly = true;
[cookie2.extensions addObject: @"foo"];
[cookie2.extensions addObject: @"bar"];
TEST(@"+[cookiesWithResponseHeaderFields:forURL:] #3",
TEST(@"+[cookiesWithResponseHeaderFields:forURI:] #3",
[(cookies = [OFHTTPCookie cookiesWithResponseHeaderFields:
[OFDictionary dictionaryWithObject:
@"foo=bar; Expires=Fri, 13 Feb 2009 23:31:30 GMT; Path=/x,"
@"qux=cookie; Expires=Fri, 13 Feb 2009 23:31:30 GMT; "
@"Domain=webkeks.org; Path=/objfw; Secure; HTTPOnly; foo; bar"
forKey: @"Set-Cookie"] forURL: URL]) isEqual:
forKey: @"Set-Cookie"] forURI: URI]) isEqual:
[OFArray arrayWithObjects: cookie1, cookie2, nil]])
TEST(@"+[requestHeaderFieldsWithCookies:]",
[[OFHTTPCookie requestHeaderFieldsWithCookies: cookies] isEqual:
[OFDictionary dictionaryWithObject: @"foo=bar; qux=cookie"
forKey: @"Cookie"]])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFINIFileTests.m
from [edfee9097f]
to [91b2a5e4f6].
︙ | | |
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
-
+
-
+
-
-
-
+
+
+
|
@"[types]\r\n"
@"integer=16\r\n"
@"bool=false\r\n"
@"float=0.25\r\n"
@"array1=foo\r\n"
@"array1=bar\r\n"
@"double=0.75\r\n";
OFURL *URL;
OFURI *URI;
OFINIFile *file;
OFINICategory *tests, *foobar, *types;
OFArray *array;
#if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_DS)
OFURL *writeURL;
OFURI *writeURI;
#endif
module = @"OFINIFile";
URL = [OFURL URLWithString: @"objfw-embedded:///testfile.ini"];
TEST(@"+[fileWithURL:encoding:]",
(file = [OFINIFile fileWithURL: URL
URI = [OFURI URIWithString: @"objfw-embedded:///testfile.ini"];
TEST(@"+[fileWithURI:encoding:]",
(file = [OFINIFile fileWithURI: URI
encoding: OFStringEncodingCodepage437]))
tests = [file categoryForName: @"tests"];
foobar = [file categoryForName: @"foobar"];
types = [file categoryForName: @"types"];
TEST(@"-[categoryForName:]",
tests != nil && foobar != nil && types != nil)
|
︙ | | |
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
-
+
+
-
+
-
+
-
+
|
R([foobar removeValueForKey: @"quxqux "]) &&
R([types removeValueForKey: @"array2"]))
module = @"OFINIFile";
/* FIXME: Find a way to write files on Nintendo DS */
#if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_DS)
writeURL = [[OFSystemInfo temporaryDirectoryURL]
URLByAppendingPathComponent: @"objfw-tests.ini"
writeURI = [[OFSystemInfo temporaryDirectoryURI]
URIByAppendingPathComponent: @"objfw-tests.ini"
isDirectory: false];
TEST(@"-[writeToFile:encoding:]",
R([file writeToURL: writeURL
R([file writeToURI: writeURI
encoding: OFStringEncodingCodepage437]) &&
[[OFString stringWithContentsOfURL: writeURL
[[OFString stringWithContentsOfURI: writeURI
encoding: OFStringEncodingCodepage437]
isEqual: output])
[[OFFileManager defaultManager] removeItemAtURL: writeURL];
[[OFFileManager defaultManager] removeItemAtURI: writeURI];
#else
(void)output;
#endif
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFMD5HashTests.m
from [97c4cf5d1a]
to [704091a6f6].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-
-
+
+
|
"\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38";
@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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI 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 [3419cbc976]
to [2822ed07d6].
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
-
+
+
|
"\xE6\x08\x8B";
@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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI 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 [f253b9db0c]
to [cda2790802].
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
-
+
+
|
"\x94\xE7\x17";
@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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI 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 [9b914752b4]
to [7bc4a06c89].
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
-
+
+
|
"\x5F\x4F\x20\x02\x4D\x15\xED\x1C\x61\x1F\xF7";
@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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI 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 [7f8af4714a]
to [f3bd53fc3c].
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
-
+
+
|
"\x67\x93\x8F\x0F\x44\x90\xB8\xF5\x35\x89\xF0\x5A\x23\x7F\x69";
@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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI 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 [22ee9524a1]
to [11ce13a89f].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
-
-
+
+
|
"\xE9\x1A\xB3\x51\x70\x8C\x1F\x3F\x56\x12\x44\x01\x91\x54";
@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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI 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 [7aae15f950]
to [9c59f1aa87].
︙ | | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
-
+
+
|
"\xA1\x8A\x41\x64\x33\x69\x21\x8C\x2A\x44\x6D\xF2\xA0";
@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"];
OFURI *URI = [OFURI URIWithString: @"objfw-embedded:///testfile.bin"];
OFStream *file = [OFURIHandler openItemAtURI: URI mode: @"r"];
TEST(@"+[hashWithAllowsSwappableMemory:]",
(SHA512 = [OFSHA512Hash hashWithAllowsSwappableMemory: true]))
while (!file.atEndOfStream) {
char buffer[128];
size_t length = [file readIntoBuffer: buffer length: 128];
|
︙ | | |
Modified tests/OFSerializationTests.m
from [8a1b6d269b]
to [ae574f4995].
︙ | | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
-
+
-
+
|
[array addObject: [OFDate dateWithTimeIntervalSince1970: 1234.5678]];
[dict setObject: @"Hello" forKey: array];
[dict setObject: @"B\"la" forKey: @"Blub"];
[list appendObject: @"Hello"];
[list appendObject: @"Wo\rld!\nHow are you?"];
[list appendObject: [OFURL URLWithString: @"https://objfw.nil.im/"]];
[list appendObject: [OFURI URIWithString: @"https://objfw.nil.im/"]];
[list appendObject:
[OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]];
[list appendObject:
[OFSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[list appendObject:
[OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[dict setObject: @"list" forKey: list];
data = [OFData dataWithItems: "0123456789:;<ABCDEFGHJIKLMNOPQRSTUVWXYZ"
count: 39];
[dict setObject: @"data" forKey: data];
UUID = [OFUUID
UUIDWithUUIDString: @"01234567-89AB-CDEF-FEDC-BA9876543210"];
[dict setObject: @"uuid" forKey: UUID];
TEST(@"-[stringBySerializing]",
(string = dict.stringBySerializing) && [string isEqual:
[OFString stringWithContentsOfURL: [OFURL URLWithString:
[OFString stringWithContentsOfURI: [OFURI URIWithString:
@"objfw-embedded:///serialization.xml"]]])
TEST(@"-[objectByDeserializing]",
[string.objectByDeserializing isEqual: dict])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/OFStringTests.m
from [cdfdf23d3d]
to [b6537107f8].
︙ | | |
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
-
-
+
+
|
#ifdef OF_HAVE_FILES
TEST(@"+[stringWithContentsOfFile:encoding]", (string = [stringClass
stringWithContentsOfFile: @"testfile.txt"
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
TEST(@"+[stringWithContentsOfURL:encoding]", (string = [stringClass
stringWithContentsOfURL: [OFURL fileURLWithPath: @"testfile.txt"]
TEST(@"+[stringWithContentsOfURI:encoding]", (string = [stringClass
stringWithContentsOfURI: [OFURI fileURIWithPath: @"testfile.txt"]
encoding: OFStringEncodingISO8859_1]) &&
[string isEqual: @"testäöü"])
#endif
TEST(@"-[appendUTFString:length:]",
R([mutableString1 appendUTF8String: "\xEF\xBB\xBF" "barqux"
length: 6]) &&
|
︙ | | |
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
|
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
|
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
|
TEST(@"-[stringBySHA512Hashing]", [C(@"asdfoobar").stringBySHA512Hashing
isEqual: @"0464c427da158b02161bb44a3090bbfc594611ef6a53603640454b56"
@"412a9247c3579a329e53a5dc74676b106755e3394f9454a2d4227324"
@"2615d32f80437d61"])
characterSet =
[OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"];
TEST(@"-[stringByURLEncodingWithAllowedCharacters:]",
[[C(@"foo\"ba'_~$]🍏🍌") stringByURLEncodingWithAllowedCharacters:
characterSet] isEqual: @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"])
TEST(@"-[stringByAddingPercentEncodingWithAllowedCharacters:]",
[[C(@"foo\"ba'_~$]🍏🍌")
stringByAddingPercentEncodingWithAllowedCharacters: characterSet]
isEqual: @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"])
TEST(@"-[stringByURLDecoding]",
[C(@"foo%20bar%22+%24%F0%9F%8D%8C").stringByURLDecoding
TEST(@"-[stringByRemovingPercentEncoding]",
[C(@"foo%20bar%22+%24%F0%9F%8D%8C").stringByRemovingPercentEncoding
isEqual: @"foo bar\"+$🍌"])
TEST(@"-[insertString:atIndex:]",
(mutableString1 = [mutableStringClass
stringWithString: @"𝄞öööbä€"]) &&
R([mutableString1 insertString: @"äöü" atIndex: 3]) &&
[mutableString1 isEqual: @"𝄞ööäöüöbä€"])
EXPECT_EXCEPTION(@"Detect invalid format in -[stringByURLDecoding] "
@"#1", OFInvalidFormatException,
[C(@"foo%xbar") stringByURLDecoding])
EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
@"#2", OFInvalidEncodingException,
[C(@"foo%FFbar") stringByURLDecoding])
EXPECT_EXCEPTION(@"Detect invalid format in "
@"-[stringByRemovingPercentEncoding] #1",
OFInvalidFormatException,
[C(@"foo%xbar") stringByRemovingPercentEncoding])
EXPECT_EXCEPTION(@"Detect invalid encoding in "
@"-[stringByRemovingPercentEncoding] #2",
OFInvalidEncodingException,
[C(@"foo%FFbar") stringByRemovingPercentEncoding])
TEST(@"-[setCharacter:atIndex:]",
(mutableString1 = [mutableStringClass
stringWithString: @"abäde"]) &&
R([mutableString1 setCharacter: 0xF6 atIndex: 2]) &&
[mutableString1 isEqual: @"aböde"] &&
R([mutableString1 setCharacter: 'c' atIndex: 2]) &&
|
︙ | | |
Modified tests/OFSystemInfoTests.m
from [79401c47ef]
to [5b9edfd152].
︙ | | |
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
-
-
+
+
-
-
+
+
-
-
+
+
|
[OFStdOut writeFormat: @"[OFSystemInfo] Operating system name: %@\n",
[OFSystemInfo operatingSystemName]];
[OFStdOut writeFormat:
@"[OFSystemInfo] Operating system version: %@\n",
[OFSystemInfo operatingSystemVersion]];
[OFStdOut writeFormat: @"[OFSystemInfo] User config URL: %@\n",
[OFSystemInfo userConfigURL].string];
[OFStdOut writeFormat: @"[OFSystemInfo] User config URI: %@\n",
[OFSystemInfo userConfigURI].string];
[OFStdOut writeFormat: @"[OFSystemInfo] User data URL: %@\n",
[OFSystemInfo userDataURL].string];
[OFStdOut writeFormat: @"[OFSystemInfo] User data URI: %@\n",
[OFSystemInfo userDataURI].string];
[OFStdOut writeFormat: @"[OFSystemInfo] Temporary directory URL: %@\n",
[OFSystemInfo temporaryDirectoryURL].string];
[OFStdOut writeFormat: @"[OFSystemInfo] Temporary directory URI: %@\n",
[OFSystemInfo temporaryDirectoryURI].string];
[OFStdOut writeFormat: @"[OFSystemInfo] CPU vendor: %@\n",
[OFSystemInfo CPUVendor]];
[OFStdOut writeFormat: @"[OFSystemInfo] CPU model: %@\n",
[OFSystemInfo CPUModel]];
|
︙ | | |
Modified tests/OFUNIXDatagramSocketTests.m
from [54c71e4e91]
to [54df3210f6].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-
-
+
+
-
+
|
void *pool = objc_autoreleasePoolPush();
OFString *path;
OFUNIXDatagramSocket *sock;
OFSocketAddress address1, address2;
char buffer[5];
#if defined(OF_HAVE_FILES) && !defined(OF_IOS)
path = [[OFSystemInfo temporaryDirectoryURL]
URLByAppendingPathComponent: [[OFUUID UUID] UUIDString]]
path = [[OFSystemInfo temporaryDirectoryURI]
URIByAppendingPathComponent: [[OFUUID UUID] UUIDString]]
.fileSystemRepresentation;
#else
/*
* We can have sockets, including UNIX sockets, while file support is
* disabled.
*
* We also use this code path for iOS, as the temporaryDirectoryURL is
* We also use this code path for iOS, as the temporaryDirectoryURI is
* too long on the iOS simulator.
*/
path = [OFString stringWithFormat: @"/tmp/%@",
[[OFUUID UUID] UUIDString]];
#endif
TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))
|
︙ | | |
Modified tests/OFUNIXStreamSocketTests.m
from [d4ca26b9c4]
to [72ce4faa3f].
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-
-
+
+
-
+
|
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
OFUNIXStreamSocket *sockClient, *sockServer, *sockAccepted;
char buffer[5];
#if defined(OF_HAVE_FILES) && !defined(OF_IOS)
path = [[OFSystemInfo temporaryDirectoryURL]
URLByAppendingPathComponent: [[OFUUID UUID] UUIDString]]
path = [[OFSystemInfo temporaryDirectoryURI]
URIByAppendingPathComponent: [[OFUUID UUID] UUIDString]]
.fileSystemRepresentation;
#else
/*
* We can have sockets, including UNIX sockets, while file support is
* disabled.
*
* We also use this code path for iOS, as the temporaryDirectoryURL is
* We also use this code path for iOS, as the temporaryDirectoryURI is
* too long on the iOS simulator.
*/
path = [OFString stringWithFormat: @"/tmp/%@",
[[OFUUID UUID] UUIDString]];
#endif
TEST(@"+[socket]", (sockClient = [OFUNIXStreamSocket socket]) &&
|
︙ | | |
Renamed and modified
tests/OFURLTests.m
[e63dcbf6b8]
to tests/OFURITests.m
[6305d6606a].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
-
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
-
-
-
+
+
+
+
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
+
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
|
* file.
*/
#include "config.h"
#import "TestsAppDelegate.h"
static OFString *const module = @"OFURL";
static OFString *URLString = @"ht%3atp://us%3Aer:p%40w@ho%3Ast:1234/"
static OFString *const module = @"OFURI";
static OFString *URIString = @"ht%3atp://us%3Aer:p%40w@ho%3Ast:1234/"
@"pa%3Fth?que%23ry=1&f%26oo=b%3dar#frag%23ment";
@implementation TestsAppDelegate (OFURLTests)
- (void)URLTests
@implementation TestsAppDelegate (OFURITests)
- (void)URITests
{
void *pool = objc_autoreleasePoolPush();
OFURL *URL1, *URL2, *URL3, *URL4, *URL5, *URL6, *URL7;
OFMutableURL *mutableURL;
OFURI *URI1, *URI2, *URI3, *URI4, *URI5, *URI6, *URI7;
OFMutableURI *mutableURI;
TEST(@"+[URLWithString:]",
R(URL1 = [OFURL URLWithString: URLString]) &&
R(URL2 = [OFURL URLWithString: @"http://foo:80"]) &&
R(URL3 = [OFURL URLWithString: @"http://bar/"]) &&
R(URL4 = [OFURL URLWithString: @"file:///etc/passwd"]) &&
R(URL5 = [OFURL URLWithString: @"http://foo/bar/qux/foo%2fbar"]) &&
R(URL6 = [OFURL URLWithString: @"https://[12:34::56:abcd]/"]) &&
R(URL7 = [OFURL URLWithString: @"https://[12:34::56:abcd]:234/"]))
TEST(@"+[URIWithString:]",
R(URI1 = [OFURI URIWithString: URIString]) &&
R(URI2 = [OFURI URIWithString: @"http://foo:80"]) &&
R(URI3 = [OFURI URIWithString: @"http://bar/"]) &&
R(URI4 = [OFURI URIWithString: @"file:///etc/passwd"]) &&
R(URI5 = [OFURI URIWithString: @"http://foo/bar/qux/foo%2fbar"]) &&
R(URI6 = [OFURI URIWithString: @"https://[12:34::56:abcd]/"]) &&
R(URI7 = [OFURI URIWithString: @"https://[12:34::56:abcd]:234/"]))
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #1",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #1",
OFInvalidFormatException,
[OFURL URLWithString: @"ht,tp://foo"])
[OFURI URIWithString: @"ht,tp://foo"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #2",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #2",
OFInvalidFormatException,
[OFURL URLWithString: @"http://f`oo"])
[OFURI URIWithString: @"http://f`oo"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #3",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #3",
OFInvalidFormatException,
[OFURL URLWithString: @"http://foo/`"])
[OFURI URIWithString: @"http://foo/`"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #4",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #4",
OFInvalidFormatException,
[OFURL URLWithString: @"http://foo/foo?`"])
[OFURI URIWithString: @"http://foo/foo?`"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #5",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #5",
OFInvalidFormatException,
[OFURL URLWithString: @"http://foo/foo?foo#`"])
[OFURI URIWithString: @"http://foo/foo?foo#`"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #6",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #6",
OFInvalidFormatException,
[OFURL URLWithString: @"https://[g]/"])
[OFURI URIWithString: @"https://[g]/"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #7",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #7",
OFInvalidFormatException,
[OFURL URLWithString: @"https://[f]:/"])
[OFURI URIWithString: @"https://[f]:/"])
EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #8",
EXPECT_EXCEPTION(@"+[URIWithString:] fails with invalid characters #8",
OFInvalidFormatException,
[OFURL URLWithString: @"https://[f]:f/"])
[OFURI URIWithString: @"https://[f]:f/"])
TEST(@"+[URLWithString:relativeToURL:]",
[[[OFURL URLWithString: @"/foo" relativeToURL: URL1] string]
TEST(@"+[URIWithString:relativeToURI:]",
[[[OFURI URIWithString: @"/foo" relativeToURI: URI1] string]
isEqual: @"ht%3atp://us%3Aer:p%40w@ho%3Ast:1234/foo"] &&
[[[OFURL URLWithString: @"foo/bar?q"
relativeToURL: [OFURL URLWithString: @"http://h/qux/quux"]]
[[[OFURI URIWithString: @"foo/bar?q"
relativeToURI: [OFURI URIWithString: @"http://h/qux/quux"]]
string] isEqual: @"http://h/qux/foo/bar?q"] &&
[[[OFURL URLWithString: @"foo/bar"
relativeToURL: [OFURL URLWithString: @"http://h/qux/?x"]]
[[[OFURI URIWithString: @"foo/bar"
relativeToURI: [OFURI URIWithString: @"http://h/qux/?x"]]
string] isEqual: @"http://h/qux/foo/bar"] &&
[[[OFURL URLWithString: @"http://foo/?q"
relativeToURL: URL1] string] isEqual: @"http://foo/?q"] &&
[[[OFURL URLWithString: @"foo"
relativeToURL: [OFURL URLWithString: @"http://foo/bar"]]
[[[OFURI URIWithString: @"http://foo/?q"
relativeToURI: URI1] string] isEqual: @"http://foo/?q"] &&
[[[OFURI URIWithString: @"foo"
relativeToURI: [OFURI URIWithString: @"http://foo/bar"]]
string] isEqual: @"http://foo/foo"] &&
[[[OFURL URLWithString: @"foo"
relativeToURL: [OFURL URLWithString: @"http://foo"]]
[[[OFURI URIWithString: @"foo"
relativeToURI: [OFURI URIWithString: @"http://foo"]]
string] isEqual: @"http://foo/foo"])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #1",
@"+[URIWithString:relativeToURI:] fails with invalid characters #1",
OFInvalidFormatException,
[OFURL URLWithString: @"`" relativeToURL: URL1])
[OFURI URIWithString: @"`" relativeToURI: URI1])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #2",
@"+[URIWithString:relativeToURI:] fails with invalid characters #2",
OFInvalidFormatException,
[OFURL URLWithString: @"/`" relativeToURL: URL1])
[OFURI URIWithString: @"/`" relativeToURI: URI1])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #3",
@"+[URIWithString:relativeToURI:] fails with invalid characters #3",
OFInvalidFormatException,
[OFURL URLWithString: @"?`" relativeToURL: URL1])
[OFURI URIWithString: @"?`" relativeToURI: URI1])
EXPECT_EXCEPTION(
@"+[URLWithString:relativeToURL:] fails with invalid characters #4",
@"+[URIWithString:relativeToURI:] fails with invalid characters #4",
OFInvalidFormatException,
[OFURL URLWithString: @"#`" relativeToURL: URL1])
[OFURI URIWithString: @"#`" relativeToURI: URI1])
#ifdef OF_HAVE_FILES
TEST(@"+[fileURLWithPath:]",
[[[OFURL fileURLWithPath: @"testfile.txt"] fileSystemRepresentation]
TEST(@"+[fileURIWithPath:]",
[[[OFURI fileURIWithPath: @"testfile.txt"] fileSystemRepresentation]
isEqual: [[OFFileManager defaultManager].currentDirectoryPath
stringByAppendingPathComponent: @"testfile.txt"]])
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
OFURL *tmp;
TEST(@"+[fileURLWithPath:] for c:\\",
(tmp = [OFURL fileURLWithPath: @"c:\\"]) &&
OFURI *tmp;
TEST(@"+[fileURIWithPath:] for c:\\",
(tmp = [OFURI fileURIWithPath: @"c:\\"]) &&
[tmp.string isEqual: @"file:///c:/"] &&
[tmp.fileSystemRepresentation isEqual: @"c:\\"])
# endif
# ifdef OF_WINDOWS
TEST(@"+[fileURLWithPath:] with UNC",
(tmp = [OFURL fileURLWithPath: @"\\\\foo\\bar"]) &&
TEST(@"+[fileURIWithPath:] with UNC",
(tmp = [OFURI fileURIWithPath: @"\\\\foo\\bar"]) &&
[tmp.host isEqual: @"foo"] && [tmp.path isEqual: @"/bar"] &&
[tmp.string isEqual: @"file://foo/bar"] &&
[tmp.fileSystemRepresentation isEqual: @"\\\\foo\\bar"] &&
(tmp = [OFURL fileURLWithPath: @"\\\\test"]) &&
(tmp = [OFURI fileURIWithPath: @"\\\\test"]) &&
[tmp.host isEqual: @"test"] && [tmp.path isEqual: @"/"] &&
[tmp.string isEqual: @"file://test/"] &&
[tmp.fileSystemRepresentation isEqual: @"\\\\test"])
# endif
#endif
TEST(@"-[string]",
[URL1.string isEqual: URLString] &&
[URL2.string isEqual: @"http://foo:80"] &&
[URL3.string isEqual: @"http://bar/"] &&
[URL4.string isEqual: @"file:///etc/passwd"])
[URI1.string isEqual: URIString] &&
[URI2.string isEqual: @"http://foo:80"] &&
[URI3.string isEqual: @"http://bar/"] &&
[URI4.string isEqual: @"file:///etc/passwd"])
TEST(@"-[scheme]",
[URL1.scheme isEqual: @"ht:tp"] && [URL4.scheme isEqual: @"file"])
[URI1.scheme isEqual: @"ht:tp"] && [URI4.scheme isEqual: @"file"])
TEST(@"-[user]", [URL1.user isEqual: @"us:er"] && URL4.user == nil)
TEST(@"-[user]", [URI1.user isEqual: @"us:er"] && URI4.user == nil)
TEST(@"-[password]",
[URL1.password isEqual: @"p@w"] && URL4.password == nil)
TEST(@"-[host]", [URL1.host isEqual: @"ho:st"] &&
[URL6.host isEqual: @"12:34::56:abcd"] &&
[URL7.host isEqual: @"12:34::56:abcd"])
TEST(@"-[port]", URL1.port.unsignedShortValue == 1234 &&
[URL4 port] == nil && URL7.port.unsignedShortValue == 234)
[URI1.password isEqual: @"p@w"] && URI4.password == nil)
TEST(@"-[host]", [URI1.host isEqual: @"ho:st"] &&
[URI6.host isEqual: @"12:34::56:abcd"] &&
[URI7.host isEqual: @"12:34::56:abcd"])
TEST(@"-[port]", URI1.port.unsignedShortValue == 1234 &&
[URI4 port] == nil && URI7.port.unsignedShortValue == 234)
TEST(@"-[path]",
[URL1.path isEqual: @"/pa?th"] &&
[URL4.path isEqual: @"/etc/passwd"])
[URI1.path isEqual: @"/pa?th"] &&
[URI4.path isEqual: @"/etc/passwd"])
TEST(@"-[pathComponents]",
[URL1.pathComponents isEqual:
[URI1.pathComponents isEqual:
[OFArray arrayWithObjects: @"/", @"pa?th", nil]] &&
[URL4.pathComponents isEqual:
[URI4.pathComponents isEqual:
[OFArray arrayWithObjects: @"/", @"etc", @"passwd", nil]] &&
[URL5.pathComponents isEqual:
[URI5.pathComponents isEqual:
[OFArray arrayWithObjects: @"/", @"bar", @"qux", @"foo/bar", nil]])
TEST(@"-[lastPathComponent]",
[[[OFURL URLWithString: @"http://host/foo//bar/baz"]
[[[OFURI URIWithString: @"http://host/foo//bar/baz"]
lastPathComponent] isEqual: @"baz"] &&
[[[OFURL URLWithString: @"http://host/foo//bar/baz/"]
[[[OFURI URIWithString: @"http://host/foo//bar/baz/"]
lastPathComponent] isEqual: @"baz"] &&
[[[OFURL URLWithString: @"http://host/foo/"]
[[[OFURI URIWithString: @"http://host/foo/"]
lastPathComponent] isEqual: @"foo"] &&
[[[OFURL URLWithString: @"http://host/"]
[[[OFURI URIWithString: @"http://host/"]
lastPathComponent] isEqual: @"/"] &&
[URL5.lastPathComponent isEqual: @"foo/bar"])
[URI5.lastPathComponent isEqual: @"foo/bar"])
TEST(@"-[query]",
[URL1.query isEqual: @"que#ry=1&f&oo=b=ar"] && URL4.query == nil)
[URI1.query isEqual: @"que#ry=1&f&oo=b=ar"] && URI4.query == nil)
TEST(@"-[queryDictionary]",
[URL1.queryDictionary isEqual:
[URI1.queryDictionary isEqual:
[OFDictionary dictionaryWithKeysAndObjects:
@"que#ry", @"1", @"f&oo", @"b=ar", nil]]);
TEST(@"-[fragment]",
[URL1.fragment isEqual: @"frag#ment"] && URL4.fragment == nil)
[URI1.fragment isEqual: @"frag#ment"] && URI4.fragment == nil)
TEST(@"-[copy]", R(URL4 = [[URL1 copy] autorelease]))
TEST(@"-[copy]", R(URI4 = [[URI1 copy] autorelease]))
TEST(@"-[isEqual:]", [URL1 isEqual: URL4] && ![URL2 isEqual: URL3] &&
[[OFURL URLWithString: @"HTTP://bar/"] isEqual: URL3])
TEST(@"-[isEqual:]", [URI1 isEqual: URI4] && ![URI2 isEqual: URI3] &&
[[OFURI URIWithString: @"HTTP://bar/"] isEqual: URI3])
TEST(@"-[hash:]", URL1.hash == URL4.hash && URL2.hash != URL3.hash)
TEST(@"-[hash:]", URI1.hash == URI4.hash && URI2.hash != URI3.hash)
EXPECT_EXCEPTION(@"Detection of invalid format",
OFInvalidFormatException, [OFURL URLWithString: @"http"])
OFInvalidFormatException, [OFURI URIWithString: @"http"])
mutableURL = [OFMutableURL URL];
mutableURI = [OFMutableURI URI];
TEST(@"-[setScheme:]",
(mutableURL.scheme = @"ht:tp") &&
[mutableURL.URLEncodedScheme isEqual: @"ht%3Atp"])
(mutableURI.scheme = @"ht:tp") &&
[mutableURI.percentEncodedScheme isEqual: @"ht%3Atp"])
TEST(@"-[setURLEncodedScheme:]",
(mutableURL.URLEncodedScheme = @"ht%3Atp") &&
[mutableURL.scheme isEqual: @"ht:tp"])
TEST(@"-[setPercentEncodedScheme:]",
(mutableURI.percentEncodedScheme = @"ht%3Atp") &&
[mutableURI.scheme isEqual: @"ht:tp"])
EXPECT_EXCEPTION(
@"-[setURLEncodedScheme:] with invalid characters fails",
OFInvalidFormatException, mutableURL.URLEncodedScheme = @"~")
@"-[setPercentEncodedScheme:] with invalid characters fails",
OFInvalidFormatException, mutableURI.percentEncodedScheme = @"~")
TEST(@"-[setHost:]",
(mutableURL.host = @"ho:st") &&
[mutableURL.URLEncodedHost isEqual: @"ho%3Ast"] &&
(mutableURL.host = @"12:34:ab") &&
[mutableURL.URLEncodedHost isEqual: @"[12:34:ab]"] &&
(mutableURL.host = @"12:34:aB") &&
[mutableURL.URLEncodedHost isEqual: @"[12:34:aB]"] &&
(mutableURL.host = @"12:34:g") &&
[mutableURL.URLEncodedHost isEqual: @"12%3A34%3Ag"])
(mutableURI.host = @"ho:st") &&
[mutableURI.percentEncodedHost isEqual: @"ho%3Ast"] &&
(mutableURI.host = @"12:34:ab") &&
[mutableURI.percentEncodedHost isEqual: @"[12:34:ab]"] &&
(mutableURI.host = @"12:34:aB") &&
[mutableURI.percentEncodedHost isEqual: @"[12:34:aB]"] &&
(mutableURI.host = @"12:34:g") &&
[mutableURI.percentEncodedHost isEqual: @"12%3A34%3Ag"])
TEST(@"-[setURLEncodedHost:]",
(mutableURL.URLEncodedHost = @"ho%3Ast") &&
[mutableURL.host isEqual: @"ho:st"] &&
(mutableURL.URLEncodedHost = @"[12:34]") &&
[mutableURL.host isEqual: @"12:34"] &&
(mutableURL.URLEncodedHost = @"[12::ab]") &&
[mutableURL.host isEqual: @"12::ab"])
TEST(@"-[setPercentEncodedHost:]",
(mutableURI.percentEncodedHost = @"ho%3Ast") &&
[mutableURI.host isEqual: @"ho:st"] &&
(mutableURI.percentEncodedHost = @"[12:34]") &&
[mutableURI.host isEqual: @"12:34"] &&
(mutableURI.percentEncodedHost = @"[12::ab]") &&
[mutableURI.host isEqual: @"12::ab"])
EXPECT_EXCEPTION(
EXPECT_EXCEPTION(@"-[setURLEncodedHost:] with invalid characters fails"
" #1", OFInvalidFormatException, mutableURL.URLEncodedHost = @"/")
@"-[setPercentEncodedHost:] with invalid characters fails #1",
OFInvalidFormatException,
mutableURI.percentEncodedHost = @"/")
EXPECT_EXCEPTION(
EXPECT_EXCEPTION(@"-[setURLEncodedHost:] with invalid characters fails"
" #2", OFInvalidFormatException,
mutableURL.URLEncodedHost = @"[12:34")
@"-[setPercentEncodedHost:] with invalid characters fails #2",
OFInvalidFormatException,
mutableURI.percentEncodedHost = @"[12:34")
EXPECT_EXCEPTION(
EXPECT_EXCEPTION(@"-[setURLEncodedHost:] with invalid characters fails"
" #3", OFInvalidFormatException,
@"-[setPercentEncodedHost:] with invalid characters fails #3",
OFInvalidFormatException, mutableURI.percentEncodedHost = @"[a::g]")
mutableURL.URLEncodedHost = @"[a::g]")
TEST(@"-[setUser:]",
(mutableURL.user = @"us:er") &&
[mutableURL.URLEncodedUser isEqual: @"us%3Aer"])
(mutableURI.user = @"us:er") &&
[mutableURI.percentEncodedUser isEqual: @"us%3Aer"])
TEST(@"-[setURLEncodedUser:]",
(mutableURL.URLEncodedUser = @"us%3Aer") &&
[mutableURL.user isEqual: @"us:er"])
TEST(@"-[setPercentEncodedUser:]",
(mutableURI.percentEncodedUser = @"us%3Aer") &&
[mutableURI.user isEqual: @"us:er"])
EXPECT_EXCEPTION(
EXPECT_EXCEPTION(@"-[setURLEncodedUser:] with invalid characters fails",
OFInvalidFormatException, mutableURL.URLEncodedHost = @"/")
@"-[setPercentEncodedUser:] with invalid characters fails",
OFInvalidFormatException,
mutableURI.percentEncodedHost = @"/")
TEST(@"-[setPassword:]",
(mutableURL.password = @"pass:word") &&
[mutableURL.URLEncodedPassword isEqual: @"pass%3Aword"])
(mutableURI.password = @"pass:word") &&
[mutableURI.percentEncodedPassword isEqual: @"pass%3Aword"])
TEST(@"-[setURLEncodedPassword:]",
(mutableURL.URLEncodedPassword = @"pass%3Aword") &&
[mutableURL.password isEqual: @"pass:word"])
TEST(@"-[setPercentEncodedPassword:]",
(mutableURI.percentEncodedPassword = @"pass%3Aword") &&
[mutableURI.password isEqual: @"pass:word"])
EXPECT_EXCEPTION(
@"-[setURLEncodedPassword:] with invalid characters fails",
OFInvalidFormatException, mutableURL.URLEncodedPassword = @"/")
@"-[setPercentEncodedPassword:] with invalid characters fails",
OFInvalidFormatException,
mutableURI.percentEncodedPassword = @"/")
TEST(@"-[setPath:]",
(mutableURL.path = @"pa/th@?") &&
[mutableURL.URLEncodedPath isEqual: @"pa/th@%3F"])
(mutableURI.path = @"pa/th@?") &&
[mutableURI.percentEncodedPath isEqual: @"pa/th@%3F"])
TEST(@"-[setURLEncodedPath:]",
(mutableURL.URLEncodedPath = @"pa/th@%3F") &&
[mutableURL.path isEqual: @"pa/th@?"])
TEST(@"-[setPercentEncodedPath:]",
(mutableURI.percentEncodedPath = @"pa/th@%3F") &&
[mutableURI.path isEqual: @"pa/th@?"])
EXPECT_EXCEPTION(
EXPECT_EXCEPTION(@"-[setURLEncodedPath:] with invalid characters fails",
OFInvalidFormatException, mutableURL.URLEncodedPath = @"?")
@"-[setPercentEncodedPath:] with invalid characters fails",
OFInvalidFormatException,
mutableURI.percentEncodedPath = @"?")
TEST(@"-[setQuery:]",
(mutableURL.query = @"que/ry?#") &&
[mutableURL.URLEncodedQuery isEqual: @"que/ry?%23"])
(mutableURI.query = @"que/ry?#") &&
[mutableURI.percentEncodedQuery isEqual: @"que/ry?%23"])
TEST(@"-[setURLEncodedQuery:]",
(mutableURL.URLEncodedQuery = @"que/ry?%23") &&
[mutableURL.query isEqual: @"que/ry?#"])
TEST(@"-[setPercentEncodedQuery:]",
(mutableURI.percentEncodedQuery = @"que/ry?%23") &&
[mutableURI.query isEqual: @"que/ry?#"])
EXPECT_EXCEPTION(
@"-[setURLEncodedQuery:] with invalid characters fails",
OFInvalidFormatException, mutableURL.URLEncodedQuery = @"`")
@"-[setPercentEncodedQuery:] with invalid characters fails",
OFInvalidFormatException,
mutableURI.percentEncodedQuery = @"`")
TEST(@"-[setQueryDictionary:]",
(mutableURL.queryDictionary =
(mutableURI.queryDictionary =
[OFDictionary dictionaryWithKeysAndObjects:
@"foo&bar", @"baz=qux", @"f=oobar", @"b&azqux", nil]) &&
[mutableURL.URLEncodedQuery isEqual:
[mutableURI.percentEncodedQuery isEqual:
@"foo%26bar=baz%3Dqux&f%3Doobar=b%26azqux"])
TEST(@"-[setFragment:]",
(mutableURL.fragment = @"frag/ment?#") &&
[mutableURL.URLEncodedFragment isEqual: @"frag/ment?%23"])
(mutableURI.fragment = @"frag/ment?#") &&
[mutableURI.percentEncodedFragment isEqual: @"frag/ment?%23"])
TEST(@"-[setURLEncodedFragment:]",
(mutableURL.URLEncodedFragment = @"frag/ment?%23") &&
[mutableURL.fragment isEqual: @"frag/ment?#"])
TEST(@"-[setPercentEncodedFragment:]",
(mutableURI.percentEncodedFragment = @"frag/ment?%23") &&
[mutableURI.fragment isEqual: @"frag/ment?#"])
EXPECT_EXCEPTION(
@"-[setURLEncodedFragment:] with invalid characters fails",
OFInvalidFormatException, mutableURL.URLEncodedFragment = @"`")
@"-[setPercentEncodedFragment:] with invalid characters fails",
OFInvalidFormatException,
mutableURI.percentEncodedFragment = @"`")
TEST(@"-[URLByAppendingPathComponent:isDirectory:]",
[[[OFURL URLWithString: @"file:///foo/bar"]
URLByAppendingPathComponent: @"qux" isDirectory: false] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qux"]] &&
[[[OFURL URLWithString: @"file:///foo/bar/"]
URLByAppendingPathComponent: @"qux" isDirectory: false] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qux"]] &&
[[[OFURL URLWithString: @"file:///foo/bar/"]
URLByAppendingPathComponent: @"qu?x" isDirectory: false] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qu%3Fx"]] &&
[[[OFURL URLWithString: @"file:///foo/bar/"]
URLByAppendingPathComponent: @"qu?x" isDirectory: true] isEqual:
[OFURL URLWithString: @"file:///foo/bar/qu%3Fx/"]])
TEST(@"-[URIByAppendingPathComponent:isDirectory:]",
[[[OFURI URIWithString: @"file:///foo/bar"]
URIByAppendingPathComponent: @"qux" isDirectory: false] isEqual:
[OFURI URIWithString: @"file:///foo/bar/qux"]] &&
[[[OFURI URIWithString: @"file:///foo/bar/"]
URIByAppendingPathComponent: @"qux" isDirectory: false] isEqual:
[OFURI URIWithString: @"file:///foo/bar/qux"]] &&
[[[OFURI URIWithString: @"file:///foo/bar/"]
URIByAppendingPathComponent: @"qu?x" isDirectory: false] isEqual:
[OFURI URIWithString: @"file:///foo/bar/qu%3Fx"]] &&
[[[OFURI URIWithString: @"file:///foo/bar/"]
URIByAppendingPathComponent: @"qu?x" isDirectory: true] isEqual:
[OFURI URIWithString: @"file:///foo/bar/qu%3Fx/"]])
TEST(@"-[URLByStandardizingPath]",
[[[OFURL URLWithString: @"http://foo/bar/.."]
URLByStandardizingPath] isEqual:
[OFURL URLWithString: @"http://foo/"]] &&
[[[OFURL URLWithString: @"http://foo/bar/%2E%2E/../qux/"]
URLByStandardizingPath] isEqual:
[OFURL URLWithString: @"http://foo/bar/qux/"]] &&
[[[OFURL URLWithString: @"http://foo/bar/./././qux/./"]
URLByStandardizingPath] isEqual:
[OFURL URLWithString: @"http://foo/bar/qux/"]] &&
[[[OFURL URLWithString: @"http://foo/bar/../../qux"]
URLByStandardizingPath] isEqual:
[OFURL URLWithString: @"http://foo/../qux"]])
TEST(@"-[URIByStandardizingPath]",
[[[OFURI URIWithString: @"http://foo/bar/.."]
URIByStandardizingPath] isEqual:
[OFURI URIWithString: @"http://foo/"]] &&
[[[OFURI URIWithString: @"http://foo/bar/%2E%2E/../qux/"]
URIByStandardizingPath] isEqual:
[OFURI URIWithString: @"http://foo/bar/qux/"]] &&
[[[OFURI URIWithString: @"http://foo/bar/./././qux/./"]
URIByStandardizingPath] isEqual:
[OFURI URIWithString: @"http://foo/bar/qux/"]] &&
[[[OFURI URIWithString: @"http://foo/bar/../../qux"]
URIByStandardizingPath] isEqual:
[OFURI URIWithString: @"http://foo/../qux"]])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/TestsAppDelegate.h
from [273606ed24]
to [951626637b].
︙ | | |
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
-
-
+
+
|
- (void)UNIXDatagramSocketTests;
@end
@interface TestsAppDelegate (OFUNIXStreamSocketTests)
- (void)UNIXStreamSocketTests;
@end
@interface TestsAppDelegate (OFURLTests)
- (void)URLTests;
@interface TestsAppDelegate (OFURITests)
- (void)URITests;
@end
@interface TestsAppDelegate (OFValueTests)
- (void)valueTests;
@end
@interface TestsAppDelegate (OFWindowsRegistryKeyTests)
|
︙ | | |
Modified tests/TestsAppDelegate.m
from [7283aa5620]
to [4f43d25380].
︙ | | |
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
-
+
|
[self UNIXStreamSocketTests];
# endif
[self kernelEventObserverTests];
#endif
#ifdef OF_HAVE_THREADS
[self threadTests];
#endif
[self URLTests];
[self URITests];
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
[self HTTPClientTests];
#endif
#ifdef OF_HAVE_SOCKETS
[self HTTPCookieTests];
[self HTTPCookieManagerTests];
#endif
|
︙ | | |
Modified tests/serialization.xml
from [9c33dfe30d]
to [f98f3b8fb6].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
+
|
<OFString>B"la</OFString>
</object>
<key>
<OFList>
<OFString>Hello</OFString>
<OFString>Wo
ld!
How are you?</OFString>
<OFURL>https://objfw.nil.im/</OFURL>
<OFURI>https://objfw.nil.im/</OFURI>
<OFXMLElement name='x'>
<children>
<OFMutableArray>
<OFXMLElement name='y'/>
<OFXMLCDATA><![CDATA[<]]></OFXMLCDATA>
</OFMutableArray>
</children>
|
︙ | | |
Modified utils/ofarc/OFArc.m
from [b2c328f575]
to [7c199387c6].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
-
+
|
#import "OFArray.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFOptionsParser.h"
#import "OFSandbox.h"
#import "OFStdIOStream.h"
#import "OFURL.h"
#import "OFURI.h"
#import "OFArc.h"
#import "GZIPArchive.h"
#import "LHAArchive.h"
#import "TarArchive.h"
#import "ZIPArchive.h"
|
︙ | | |
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
-
+
|
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[OFStdErr writeString: @"\r"];
[OFStdErr writeLine: OF_LOCALIZED(
@"failed_to_create_directory",
@"Failed to create directory %[dir]: %[error]",
@"dir", e.URL.fileSystemRepresentation,
@"dir", e.URI.fileSystemRepresentation,
@"error", error)];
_exitStatus = 1;
} @catch (OFOpenItemFailedException *e) {
OFString *error = [OFString
stringWithCString: strerror(e.errNo)
encoding: [OFLocale encoding]];
[OFStdErr writeString: @"\r"];
|
︙ | | |
Modified utils/ofhttp/OFHTTP.m
from [0c6715c4db]
to [d8707f71b6].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
|
# import "OFPlugin.h"
#endif
#import "OFSandbox.h"
#import "OFStdIOStream.h"
#import "OFSystemInfo.h"
#import "OFTCPSocket.h"
#import "OFTLSStream.h"
#import "OFURL.h"
#import "OFURI.h"
#ifdef HAVE_TLS_SUPPORT
# import "ObjFWTLS.h"
#endif
#import "OFConnectionFailedException.h"
#import "OFGetItemAttributesFailedException.h"
|
︙ | | |
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
-
+
+
-
+
-
+
|
#define GIBIBYTE (1024 * 1024 * 1024)
#define MEBIBYTE (1024 * 1024)
#define KIBIBYTE (1024)
@interface OFHTTP: OFObject <OFApplicationDelegate, OFHTTPClientDelegate,
OFStreamDelegate>
{
OFArray OF_GENERIC(OFString *) *_URLs;
size_t _URLIndex;
OFArray OF_GENERIC(OFString *) *_URIs;
size_t _URIIndex;
int _errorCode;
OFString *_outputPath, *_currentFileName;
bool _continue, _force, _detectFileName, _detectFileNameRequest;
bool _detectedFileName, _quiet, _verbose, _insecure, _ignoreStatus;
bool _useUnicode;
OFStream *_body;
OFHTTPRequestMethod _method;
OFMutableDictionary *_clientHeaders;
OFHTTPClient *_HTTPClient;
char *_buffer;
OFStream *_output;
unsigned long long _received, _length, _resumedFrom;
ProgressBar *_progressBar;
}
- (void)downloadNextURL;
- (void)downloadNextURI;
@end
#ifdef HAVE_TLS_SUPPORT
void
_reference_to_ObjFWTLS(void)
{
_ObjFWTLS_reference = 1;
}
#endif
OF_APPLICATION_DELEGATE(OFHTTP)
static void
help(OFStream *stream, bool full, int status)
{
[OFStdErr writeLine:
OF_LOCALIZED(@"usage",
@"Usage: %[prog] -[cehHmoOPqv] url1 [url2 ...]",
@"Usage: %[prog] -[cehHmoOPqv] uri1 [uri2 ...]",
@"prog", [OFApplication programName])];
if (full) {
[stream writeString: @"\n"];
[stream writeLine: OF_LOCALIZED(@"full_usage",
@"Options:\n "
@"-b --body "
|
︙ | | |
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
|
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
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
|
-
+
-
+
-
+
-
-
+
+
-
+
|
[sandbox unveilPath: @"/etc/ssl" permissions: @"r"];
sandbox.allowsUnveil = false;
[OFApplication of_activateSandbox: sandbox];
#endif
_outputPath = [outputPath copy];
_URLs = [optionsParser.remainingArguments copy];
_URIs = [optionsParser.remainingArguments copy];
if (_URLs.count < 1)
if (_URIs.count < 1)
help(OFStdErr, false, 1);
if (_quiet && _verbose) {
[OFStdErr writeLine: OF_LOCALIZED(@"quiet_xor_verbose",
@"%[prog]: -q / --quiet and -v / --verbose are mutually "
@"exclusive!",
@"prog", [OFApplication programName])];
[OFApplication terminateWithStatus: 1];
}
if (_outputPath != nil && _detectFileName) {
[OFStdErr writeLine: OF_LOCALIZED(
@"output_xor_detect_filename",
@"%[prog]: -o / --output and -O / --detect-filename are "
@"mutually exclusive!",
@"prog", [OFApplication programName])];
[OFApplication terminateWithStatus: 1];
}
if (_outputPath != nil && _URLs.count > 1) {
if (_outputPath != nil && _URIs.count > 1) {
[OFStdErr writeLine:
OF_LOCALIZED(@"output_only_with_one_url",
@"%[prog]: Cannot use -o / --output when more than one URL "
OF_LOCALIZED(@"output_only_with_one_uri",
@"%[prog]: Cannot use -o / --output when more than one URI "
@"has been specified!",
@"prog", [OFApplication programName])];
[OFApplication terminateWithStatus: 1];
}
if (_insecure)
_HTTPClient.allowsInsecureRedirects = true;
#ifdef OF_WINDOWS
_useUnicode = [OFSystemInfo isWindowsNT];
#else
_useUnicode = ([OFLocale encoding] == OFStringEncodingUTF8);
#endif
[self performSelector: @selector(downloadNextURL) afterDelay: 0];
[self performSelector: @selector(downloadNextURI) afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didCreateTLSStream: (OFTLSStream *)stream
request: (OFHTTPRequest *)request
{
/* Use setter instead of property access to work around GCC bug. */
|
︙ | | |
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
-
+
|
char buffer[4096];
size_t length = [_body readIntoBuffer: buffer length: 4096];
[body writeBuffer: buffer length: length];
}
}
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirect: (OFURL *)URL
shouldFollowRedirect: (OFURI *)URI
statusCode: (short)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
{
if (_verbose) {
void *pool = objc_autoreleasePoolPush();
OFDictionary OF_GENERIC(OFString *, OFString *) *headers =
|
︙ | | |
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
|
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
[OFStdOut writeFormat: @" %@: %@\n", key, object];
objc_autoreleasePoolPop(pool);
}
if (!_quiet) {
if (_useUnicode)
[OFStdOut writeFormat: @"☇ %@", URL.string];
[OFStdOut writeFormat: @"☇ %@", URI.string];
else
[OFStdOut writeFormat: @"< %@", URL.string];
[OFStdOut writeFormat: @"< %@", URI.string];
}
_length = 0;
return true;
}
- (bool)stream: (OFStream *)response
didReadIntoBuffer: (void *)buffer
length: (size_t)length
exception: (id)exception
{
if (exception != nil) {
OFString *URL;
OFString *URI;
[_progressBar stop];
[_progressBar draw];
[_progressBar release];
_progressBar = nil;
if (!_quiet) {
[OFStdOut writeString: @"\n "];
[OFStdOut writeLine: OF_LOCALIZED(@"download_error",
@"Error!")];
}
URL = [_URLs objectAtIndex: _URLIndex - 1];
URI = [_URIs objectAtIndex: _URIIndex - 1];
[OFStdErr writeLine: OF_LOCALIZED(
@"download_failed_exception",
@"%[prog]: Failed to download <%[url]>!\n"
@"%[prog]: Failed to download <%[uri]>!\n"
@" %[exception]",
@"prog", [OFApplication programName],
@"url", URL,
@"uri", URI,
@"exception", exception)];
_errorCode = 1;
[self performSelector: @selector(downloadNextURL)
[self performSelector: @selector(downloadNextURI)
afterDelay: 0];
return false;
}
[_output writeBuffer: buffer length: length];
_received += length;
|
︙ | | |
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
|
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
|
-
+
|
if (!_quiet) {
[OFStdOut writeString: @"\n "];
[OFStdOut writeLine:
OF_LOCALIZED(@"download_done", @"Done!")];
}
[self performSelector: @selector(downloadNextURL)
[self performSelector: @selector(downloadNextURI)
afterDelay: 0];
return false;
}
return true;
}
|
︙ | | |
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
|
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
|
-
+
-
+
-
+
-
+
-
+
-
+
|
if ([exception isKindOfClass:
[OFResolveHostFailedException class]]) {
if (!_quiet)
[OFStdOut writeString: @"\n"];
[OFStdErr writeLine:
OF_LOCALIZED(@"download_resolve_host_failed",
@"%[prog]: Failed to download <%[url]>!\n"
@"%[prog]: Failed to download <%[uri]>!\n"
@" Failed to resolve host: %[exception]",
@"prog", [OFApplication programName],
@"url", request.URL.string,
@"uri", request.URI.string,
@"exception", exception)];
} else if ([exception isKindOfClass:
[OFConnectionFailedException class]]) {
if (!_quiet)
[OFStdOut writeString: @"\n"];
[OFStdErr writeLine:
OF_LOCALIZED(@"download_failed_connection_failed",
@"%[prog]: Failed to download <%[url]>!\n"
@"%[prog]: Failed to download <%[uri]>!\n"
@" Connection failed: %[exception]",
@"prog", [OFApplication programName],
@"url", request.URL.string,
@"uri", request.URI.string,
@"exception", exception)];
} else if ([exception isKindOfClass:
[OFInvalidServerResponseException class]]) {
if (!_quiet)
[OFStdOut writeString: @"\n"];
[OFStdErr writeLine: OF_LOCALIZED(
@"download_failed_invalid_server_response",
@"%[prog]: Failed to download <%[url]>!\n"
@"%[prog]: Failed to download <%[uri]>!\n"
@" Invalid server response!",
@"prog", [OFApplication programName],
@"url", request.URL.string)];
@"uri", request.URI.string)];
} else if ([exception isKindOfClass:
[OFUnsupportedProtocolException class]]) {
if (!_quiet)
[OFStdOut writeString: @"\n"];
[OFStdErr writeLine: OF_LOCALIZED(@"no_tls_support",
@"%[prog]: No TLS support in ObjFW!\n"
|
︙ | | |
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
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
|
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
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
|
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
error = OF_LOCALIZED(
@"download_failed_read_or_write_failed_"
@"write",
@"Write failed");
[OFStdErr writeLine: OF_LOCALIZED(
@"download_failed_read_or_write_failed",
@"%[prog]: Failed to download <%[url]>!\n"
@"%[prog]: Failed to download <%[uri]>!\n"
@" %[error]: %[exception]",
@"prog", [OFApplication programName],
@"url", request.URL.string,
@"uri", request.URI.string,
@"error", error,
@"exception", exception)];
} else if ([exception isKindOfClass:
[OFHTTPRequestFailedException class]]) {
short statusCode;
OFString *codeString;
if (_ignoreStatus) {
exception = nil;
goto after_exception_handling;
}
statusCode = response.statusCode;
codeString = [OFString stringWithFormat: @"%hd %@",
statusCode, OFHTTPStatusCodeString(statusCode)];
[OFStdErr writeLine: OF_LOCALIZED(@"download_failed",
@"%[prog]: Failed to download <%[url]>!\n"
@"%[prog]: Failed to download <%[uri]>!\n"
@" HTTP status code: %[code]",
@"prog", [OFApplication programName],
@"url", request.URL.string,
@"uri", request.URI.string,
@"code", codeString)];
} else
@throw exception;
_errorCode = 1;
[self performSelector: @selector(downloadNextURL)
[self performSelector: @selector(downloadNextURI)
afterDelay: 0];
return;
}
after_exception_handling:
if (_method == OFHTTPRequestMethodHead)
goto next;
if (_detectFileNameRequest) {
_currentFileName = [fileNameFromContentDisposition(
[response.headers objectForKey: @"Content-Disposition"])
copy];
_detectedFileName = true;
/* Handle this URL on the next -[downloadNextURL] call */
_URLIndex--;
/* Handle this URI on the next -[downloadNextURI] call */
_URIIndex--;
[self performSelector: @selector(downloadNextURL)
[self performSelector: @selector(downloadNextURI)
afterDelay: 0];
return;
}
if ([_outputPath isEqual: @"-"])
_output = [OFStdOut copy];
else {
|
︙ | | |
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
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
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
|
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
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
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
|
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
[response asyncReadIntoBuffer: _buffer length: [OFSystemInfo pageSize]];
return;
next:
[_currentFileName release];
_currentFileName = nil;
[self performSelector: @selector(downloadNextURL) afterDelay: 0];
[self performSelector: @selector(downloadNextURI) afterDelay: 0];
}
- (void)downloadNextURL
- (void)downloadNextURI
{
OFString *URLString = nil;
OFURL *URL;
OFString *URIString = nil;
OFURI *URI;
OFMutableDictionary *clientHeaders;
OFHTTPRequest *request;
_received = _length = _resumedFrom = 0;
if (_output != OFStdOut)
[_output release];
_output = nil;
if (_URLIndex >= _URLs.count)
if (_URIIndex >= _URIs.count)
[OFApplication terminateWithStatus: _errorCode];
@try {
URLString = [_URLs objectAtIndex: _URLIndex++];
URL = [OFURL URLWithString: URLString];
URIString = [_URIs objectAtIndex: _URIIndex++];
URI = [OFURI URIWithString: URIString];
} @catch (OFInvalidFormatException *e) {
[OFStdErr writeLine: OF_LOCALIZED(@"invalid_url",
@"%[prog]: Invalid URL: <%[url]>!",
[OFStdErr writeLine: OF_LOCALIZED(@"invalid_uri",
@"%[prog]: Invalid URI: <%[uri]>!",
@"prog", [OFApplication programName],
@"url", URLString)];
@"uri", URIString)];
_errorCode = 1;
goto next;
}
if (![URL.scheme isEqual: @"http"] && ![URL.scheme isEqual: @"https"]) {
if (![URI.scheme isEqual: @"http"] && ![URI.scheme isEqual: @"https"]) {
[OFStdErr writeLine: OF_LOCALIZED(@"invalid_scheme",
@"%[prog]: Invalid scheme: <%[url]>!",
@"%[prog]: Invalid scheme: <%[uri]>!",
@"prog", [OFApplication programName],
@"url", URLString)];
@"uri", URIString)];
_errorCode = 1;
goto next;
}
clientHeaders = [[_clientHeaders mutableCopy] autorelease];
if (_detectFileName && !_detectedFileName) {
if (!_quiet) {
if (_useUnicode)
[OFStdOut writeFormat: @"⠒ %@", URL.string];
[OFStdOut writeFormat: @"⠒ %@", URI.string];
else
[OFStdOut writeFormat: @"? %@", URL.string];
[OFStdOut writeFormat: @"? %@", URI.string];
}
request = [OFHTTPRequest requestWithURL: URL];
request = [OFHTTPRequest requestWithURI: URI];
request.headers = clientHeaders;
request.method = OFHTTPRequestMethodHead;
_detectFileNameRequest = true;
[_HTTPClient asyncPerformRequest: request];
return;
}
if (!_detectedFileName) {
[_currentFileName release];
_currentFileName = nil;
} else
_detectedFileName = false;
if (_currentFileName == nil)
_currentFileName = [_outputPath copy];
if (_currentFileName == nil)
_currentFileName = [URL.path.lastPathComponent copy];
_currentFileName = [URI.path.lastPathComponent copy];
if ([_currentFileName isEqual: @"/"]) {
[_currentFileName release];
_currentFileName = nil;
}
if (_currentFileName == nil)
|
︙ | | |
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
|
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
|
-
+
-
+
-
+
-
+
|
[clientHeaders setObject: range forKey: @"Range"];
} @catch (OFGetItemAttributesFailedException *e) {
}
}
if (!_quiet) {
if (_useUnicode)
[OFStdOut writeFormat: @"⇣ %@", URL.string];
[OFStdOut writeFormat: @"⇣ %@", URI.string];
else
[OFStdOut writeFormat: @"< %@", URL.string];
[OFStdOut writeFormat: @"< %@", URI.string];
}
request = [OFHTTPRequest requestWithURL: URL];
request = [OFHTTPRequest requestWithURI: URI];
request.headers = clientHeaders;
request.method = _method;
_detectFileNameRequest = false;
[_HTTPClient asyncPerformRequest: request];
return;
next:
[self performSelector: @selector(downloadNextURL) afterDelay: 0];
[self performSelector: @selector(downloadNextURI) afterDelay: 0];
}
@end
|
Modified utils/ofhttp/lang/de.json
from [4915bd731f]
to [839a028930].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
{
"usage": "Benutzung: %[prog] -[cehHmoOPqv] url1 [url2 ...]",
"usage": "Benutzung: %[prog] -[cehHmoOPqv] uri1 [uri2 ...]",
"full_usage": [
"Optionen:\n",
" -b --body Angegebene Datei als Body übergeben\n",
" (- für Standard-Eingabe)\n",
" -c --continue Download von existierender Datei ",
"fortsetzen\n",
" -f --force Existierende Datei überschreiben\n",
|
︙ | | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
|
"%[prog]: -q / --quiet und -v / --verbose schließen sich gegenseitig ",
"aus!"
],
"output_xor_detect_filename": [
"%[prog]: -o / --output und -O / --detect-filename schließen sich ",
"gegenseitig aus!"
],
"output_only_with_one_url": [
"%[prog]: -o / --output kann nicht mit mehr als einer URL benutzt ",
"output_only_with_one_uri": [
"%[prog]: -o / --output kann nicht mit mehr als einer URI benutzt ",
"werden!"
],
"download_resolve_host_failed": [
"%[prog]: Fehler beim Download von <%[url]>!\n",
"%[prog]: Fehler beim Download von <%[uri]>!\n",
" Host auflösen fehlgeschlagen: %[exception]"
],
"download_failed_connection_failed": [
"%[prog]: Fehler beim Download von <%[url]>!\n",
"%[prog]: Fehler beim Download von <%[uri]>!\n",
" Verbindung fehlgeschlagen: %[exception]"
],
"download_failed_invalid_server_response": [
"%[prog]: Fehler beim Download von <%[url]>!\n",
"%[prog]: Fehler beim Download von <%[uri]>!\n",
" Ungültige Antwort vom Server!"
],
"no_tls_support": [
"%[prog]: Keine TLS-Unterstützung in ObjFW!\n",
" Um via HTTPS runterzuladen müssen Sie entweder ObjFW mit TLS-",
"Unterstützung\n",
" kompilieren oder eine Bibliothek mittels „preload” laden, welche ",
"TLS-Support\n",
" zu ObjFW hinzufügt!"
],
"download_failed_read_or_write_failed_any": "Lesen oder Schreiben",
"download_failed_read_or_write_failed_read": "Lesen",
"download_failed_read_or_write_failed_write": "Schreiben",
"download_failed_read_or_write_failed": [
"%[prog]: Fehler beim Download von <%[url]>!\n",
"%[prog]: Fehler beim Download von <%[uri]>!\n",
" %[error]: %[exception]"
],
"download_failed": [
"%[prog]: Fehler beim Download von <%[url]>!\n",
"%[prog]: Fehler beim Download von <%[uri]>!\n",
" HTTP Status-Code: %[code]"
],
"download_error": "Fehler!",
"download_failed_exception": [
"%[prog]: Fehler beim Download von <%[url]>!\n",
"%[prog]: Fehler beim Download von <%[uri]>!\n",
" %[exception]"
],
"download_done": "Fertig!",
"invalid_url": "%[prog]: Ungültige URL: <%[url]>!",
"invalid_scheme": "%[prog]: Ungültiges Schema: <%[url]>!",
"invalid_uri": "%[prog]: Ungültige URI: <%[uri]>!",
"invalid_scheme": "%[prog]: Ungültiges Schema: <%[uri]>!",
"type_unknown": "unbekannt",
"size_gib": "%[num] GiB",
"size_mib": "%[num] MiB",
"size_kib": "%[num] KiB",
"size_bytes": [
[
{"num == 1": "1 Byte"},
|
︙ | | |