︙ | | | ︙ | |
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
|
} @finally {
free(UTF8String2);
}
return self;
}
- (instancetype)initWithString: (OFString *)string
relativeToURL: (OFURL *)URL
{
char *UTF8String, *UTF8String2 = NULL;
if ([string containsString: @"://"])
return [self initWithString: string];
self = [super init];
|
|
<
|
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
} @finally {
free(UTF8String2);
}
return self;
}
- (instancetype)initWithString: (OFString *)string relativeToURL: (OFURL *)URL
{
char *UTF8String, *UTF8String2 = NULL;
if ([string containsString: @"://"])
return [self initWithString: string];
self = [super init];
|
︙ | | | ︙ | |
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
|
#ifdef OF_HAVE_FILES
- (instancetype)initFileURLWithPath: (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];
return self;
}
- (instancetype)initFileURLWithPath: (OFString *)path
isDirectory: (bool)isDirectory
{
|
<
<
|
<
|
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
#ifdef OF_HAVE_FILES
- (instancetype)initFileURLWithPath: (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];
return self;
}
- (instancetype)initFileURLWithPath: (OFString *)path
isDirectory: (bool)isDirectory
{
|
︙ | | | ︙ | |
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
|
#ifdef OF_HAVE_FILES
if (isFile) {
OFString *path = [_URLEncodedPath
of_URLPathToPathWithURLEncodedHost: nil];
ret = [[path.pathComponents mutableCopy] autorelease];
if (![ret.firstObject isEqual: @"/"])
[ret insertObject: @"/"
atIndex: 0];
} else
#endif
ret = [[[_URLEncodedPath 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 =
|
|
<
|
<
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
|
#ifdef OF_HAVE_FILES
if (isFile) {
OFString *path = [_URLEncodedPath
of_URLPathToPathWithURLEncodedHost: nil];
ret = [[path.pathComponents mutableCopy] autorelease];
if (![ret.firstObject isEqual: @"/"])
[ret insertObject: @"/" atIndex: 0];
} else
#endif
ret = [[[_URLEncodedPath 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 =
|
︙ | | | ︙ | |
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
|
return [path autorelease];
}
#endif
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component];
[URL makeImmutable];
return URL;
}
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
isDirectory: (bool)isDirectory
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component
isDirectory: isDirectory];
[URL makeImmutable];
return URL;
}
- (OFURL *)URLByStandardizingPath
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL standardizePath];
[URL makeImmutable];
return URL;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@>",
self.class, self.string];
|
<
<
<
|
<
<
<
<
|
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
|
return [path autorelease];
}
#endif
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component];
[URL makeImmutable];
return URL;
}
- (OFURL *)URLByAppendingPathComponent: (OFString *)component
isDirectory: (bool)isDirectory
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL appendPathComponent: component isDirectory: isDirectory];
[URL makeImmutable];
return URL;
}
- (OFURL *)URLByStandardizingPath
{
OFMutableURL *URL = [[self mutableCopy] autorelease];
[URL standardizePath];
[URL makeImmutable];
return URL;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@>",
self.class, self.string];
|
︙ | | | ︙ | |