* Headers/Foundation/NSFileManager.h: Added declaration for new method

here.
	* Source/NSFileManager.m: Added implementation for the method 
	-(BOOL)createDirectoryAtPath:withIntermediateDirectories:attributes:
	error:.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26971 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2008-10-27 00:54:29 +00:00
parent eb23f2ee93
commit 8c7739da4e
3 changed files with 52 additions and 0 deletions

View file

@ -1,3 +1,11 @@
2008-10-26 20:59-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Headers/Foundation/NSFileManager.h: Added declaration for new method
here.
* Source/NSFileManager.m: Added implementation for the method
-(BOOL)createDirectoryAtPath:withIntermediateDirectories:attributes:
error:.
2008-10-19 Wolfgang Lux
* configure.ac: fix test for sychronization in objc runtime.

View file

@ -206,6 +206,10 @@ extern "C" {
- (BOOL) copyPath: (NSString*)source
toPath: (NSString*)destination
handler: (id)handler;
- (BOOL) createDirectoryAtPath: (NSString *)path
withIntermediateDirectories: (BOOL)flag
attributes: (NSDictionary *)attributes
error: (NSError **) error;
- (BOOL) createDirectoryAtPath: (NSString*)path
attributes: (NSDictionary*)attributes;
- (BOOL) createFileAtPath: (NSString*)path

View file

@ -670,6 +670,46 @@ static NSStringEncoding defaultEncoding;
}
}
/**
* Creates a new directory and all intermediate directories
* if flag is YES, creates only the last directory in the path
* if flag is NO. The directory is created with the attributes
* specified in attributes and any error is returned in error.<br />
* returns YES on success, NO on failure.
*/
- (BOOL) createDirectoryAtPath: (NSString *)path
withIntermediateDirectories: (BOOL)flag
attributes: (NSDictionary *)attributes
error: (NSError **) error
{
BOOL result = NO;
if(flag == YES)
{
NSEnumerator *paths = [[path pathComponents] objectEnumerator];
NSString *path = nil;
NSString *dir = [NSString string];
while((path = (NSString *)[paths nextObject]) != nil)
{
dir = [dir stringByAppendingPathComponent: path];
result = [self createDirectoryAtPath: dir
attributes: attributes];
}
}
else
{
NSString *dir = [path lastPathComponent];
result = [self createDirectoryAtPath: dir
attributes: attributes];
}
if(error != NULL)
{
*error = [NSError _last];
}
return result;
}
/**
* Creates a new directory, and sets its attributes as specified.<br />
* Creates other directories in the path as necessary.<br />