ObjFW  Check-in [79183b7fe9]

Overview
Comment:Add +[OFFile createDirectoryAtPath:createParents:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 79183b7fe9eecad0f19e7179e2b3504a5a40cf20333baec5a95dbfab63dfb8c2
User & Date: js on 2012-03-17 22:22:41
Other Links: manifest | tags
Context
2012-03-19
13:19
.hgignore -> .gitignore check-in: 8d0a41b0d3 user: js tags: trunk
2012-03-17
22:22
Add +[OFFile createDirectoryAtPath:createParents:]. check-in: 79183b7fe9 user: js tags: trunk
21:36
Update buildsys. check-in: cc91153554 user: js tags: trunk
Changes

Modified src/OFFile.h from [06cd3c5eac] to [a381f6647c].

91
92
93
94
95
96
97









98
99
100
101
102
103
104
/**
 * \brief Creates a directory at the specified path.
 *
 * \param path The path of the directory
 */
+ (void)createDirectoryAtPath: (OFString*)path;










/**
 * \brief Returns an array with the files in the specified directory.
 *
 * \param path The path of the directory
 * \return An array of OFStrings with the files at the specified path
 */
+ (OFArray*)filesInDirectoryAtPath: (OFString*)path;







>
>
>
>
>
>
>
>
>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
 * \brief Creates a directory at the specified path.
 *
 * \param path The path of the directory
 */
+ (void)createDirectoryAtPath: (OFString*)path;

/**
 * \brief Creates a directory at the specified path.
 *
 * \param path The path of the directory
 * \param createParents Whether to create the parents of the directory
 */
+ (void)createDirectoryAtPath: (OFString*)path
		createParents: (BOOL)createParents;

/**
 * \brief Returns an array with the files in the specified directory.
 *
 * \param path The path of the directory
 * \return An array of OFStrings with the files at the specified path
 */
+ (OFArray*)filesInDirectoryAtPath: (OFString*)path;

Modified src/OFFile.m from [7a546860fc] to [83d1b0c935].

244
245
246
247
248
249
250





































251
252
253
254
255
256
257
#else
	if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
		@throw [OFCreateDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}






































+ (OFArray*)filesInDirectoryAtPath: (OFString*)path
{
	OFAutoreleasePool *pool;
	OFMutableArray *files = [OFMutableArray array];

#ifndef _WIN32







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
#else
	if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
		@throw [OFCreateDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}

+ (void)createDirectoryAtPath: (OFString*)path
		createParents: (BOOL)createParents
{
	OFAutoreleasePool *pool, *pool2;
	OFArray *pathComponents;
	OFString *currentPath = nil, *component;
	OFEnumerator *enumerator;

	if (!createParents) {
		[OFFile createDirectoryAtPath: path];
		return;
	}

	pool = [[OFAutoreleasePool alloc] init];

	pathComponents = [path pathComponents];
	enumerator = [pathComponents objectEnumerator];
	pool2 = [[OFAutoreleasePool alloc] init];
	while ((component = [enumerator nextObject]) != nil) {
		if (currentPath != nil)
			currentPath = [OFString
			    stringWithPath: currentPath, component, nil];
		else
			currentPath = component;

		if (![currentPath isEqual: @""] &&
		    ![OFFile directoryExistsAtPath: currentPath])
			[OFFile createDirectoryAtPath: currentPath];

		[currentPath retain];
		[pool2 releaseObjects];
		[currentPath autorelease];
	}

	[pool release];
}

+ (OFArray*)filesInDirectoryAtPath: (OFString*)path
{
	OFAutoreleasePool *pool;
	OFMutableArray *files = [OFMutableArray array];

#ifndef _WIN32