mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
* 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:
parent
eb23f2ee93
commit
8c7739da4e
3 changed files with 52 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 />
|
||||
|
|
Loading…
Reference in a new issue