308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
-
|
- (void)createDirectoryAtURL: (OFURL *)URL_
createParents: (bool)createParents
{
void *pool = objc_autoreleasePoolPush();
OFMutableURL *URL = [[URL_ mutableCopy] autorelease];
OFArray OF_GENERIC(OFString *) *components;
OFString *currentPath = nil;
if (URL == nil)
@throw [OFInvalidArgumentException exception];
if (!createParents) {
[self createDirectoryAtURL: URL];
return;
|
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
|
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
+
-
+
-
-
-
-
-
+
-
+
-
-
|
* 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;
}
components = [[URL.pathComponents retain] autorelease];
components = [URL.URLEncodedPath componentsSeparatedByString: @"/"];
URL.URLEncodedPath = @"/";
for (OFString *component in components) {
if (currentPath != nil)
currentPath = [currentPath
stringByAppendingFormat: @"/%@", component];
else
currentPath = component;
[URL appendPathComponent: component];
URL.URLEncodedPath = currentPath;
if (![URL.URLEncodedPath isEqual: @"/"] &&
if (currentPath.length > 0 &&
![self directoryExistsAtURL: URL])
[self createDirectoryAtURL: URL];
}
objc_autoreleasePoolPop(pool);
}
|