ObjFW  Check-in [e076f9c2ad]

Overview
Comment:Adjust createDirectoryAtURL: to new path handling
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e076f9c2ad6f75562459686265f78cf2a2dc7e0fa61f0450db39553577d105be
User & Date: js on 2019-04-07 23:15:17
Other Links: manifest | tags
Context
2019-04-08
15:54
OFXMLParser: Minor style improvement check-in: 5fe20406aa user: js tags: trunk
2019-04-07
23:15
Adjust createDirectoryAtURL: to new path handling check-in: e076f9c2ad user: js tags: trunk
23:05
Add -[OFMutableURL appendPathComponent:] check-in: 7bf788b164 user: js tags: trunk
Changes

Modified src/OFFileManager.m from [f668bb35ed] to [5e553d195f].

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);
}