123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
pos = [fileName rangeOfString: @"."
options: OF_STRING_SEARCH_BACKWARDS].location;
if (pos == OF_NOT_FOUND || pos == 0) {
objc_autoreleasePoolPop(pool);
return @"";
}
ret = [fileName substringWithRange:
of_range(pos + 1, fileName.length - pos - 1)];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (OFString *)stringByDeletingLastPathComponent
|
|
<
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
pos = [fileName rangeOfString: @"."
options: OF_STRING_SEARCH_BACKWARDS].location;
if (pos == OF_NOT_FOUND || pos == 0) {
objc_autoreleasePoolPop(pool);
return @"";
}
ret = [fileName substringFromIndex: pos + 1];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (OFString *)stringByDeletingLastPathComponent
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
pos = [fileName rangeOfString: @"."
options: OF_STRING_SEARCH_BACKWARDS].location;
if (pos == OF_NOT_FOUND || pos == 0) {
objc_autoreleasePoolPop(pool);
return [[self copy] autorelease];
}
fileName = [fileName substringWithRange: of_range(0, pos)];
[components replaceObjectAtIndex: components.count - 1
withObject: fileName];
ret = [OFString pathWithComponents: components];
[ret retain];
objc_autoreleasePoolPop(pool);
|
|
|
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
pos = [fileName rangeOfString: @"."
options: OF_STRING_SEARCH_BACKWARDS].location;
if (pos == OF_NOT_FOUND || pos == 0) {
objc_autoreleasePoolPop(pool);
return [[self copy] autorelease];
}
fileName = [fileName substringToIndex: pos];
[components replaceObjectAtIndex: components.count - 1
withObject: fileName];
ret = [OFString pathWithComponents: components];
[ret retain];
objc_autoreleasePoolPop(pool);
|
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
}
- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost
{
OFString *path = self;
if (path.length > 1 && [path hasSuffix: @"/"])
path = [path substringWithRange: of_range(0, path.length - 1)];
OFMutableArray OF_GENERIC(OFString *) *components;
size_t count;
path = [path substringWithRange: of_range(1, path.length - 1)];
components = [[[path
componentsSeparatedByString: @"/"] mutableCopy] autorelease];
count = components.count;
for (size_t i = 0; i < count; i++) {
OFString *component = [components objectAtIndex: i];
|
|
|
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
}
- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost
{
OFString *path = self;
if (path.length > 1 && [path hasSuffix: @"/"])
path = [path substringToIndex: path.length - 1];
OFMutableArray OF_GENERIC(OFString *) *components;
size_t count;
path = [path substringFromIndex: 1];
components = [[[path
componentsSeparatedByString: @"/"] mutableCopy] autorelease];
count = components.count;
for (size_t i = 0; i < count; i++) {
OFString *component = [components objectAtIndex: i];
|