Apply patch for bug #32899

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32794 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-04-07 05:09:08 +00:00
parent fd7c0f05a3
commit d3c38af54b
3 changed files with 38 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2011-04-07 Chris Armstrong <carmstrong@fastmail.com.au>
* Source/NSFileManager.m: Fix bug creating intermediary directories.
* Tests/base/NSFileManager/general.m: Add test for whether intermediary
directories are created.
2011-04-06 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/AGSparser.m: ignore __attribute__ in declarator to fix bug

View file

@ -720,8 +720,19 @@ static NSStringEncoding defaultEncoding;
}
else
{
result = [self createDirectoryAtPath: [path lastPathComponent]
attributes: attributes];
BOOL isDir;
if ([self fileExistsAtPath: [path stringByDeletingLastPathComponent]
isDirectory: &isDir] && isDir)
{
result = [self createDirectoryAtPath: path
attributes: attributes];
}
else
{
result = NO;
ASSIGN(_lastError, @"Could not create directory - intermediate paths did not exist or were not a directory");
}
}
if (error != NULL)

View file

@ -10,6 +10,7 @@ int main()
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSFileManager *mgr = [NSFileManager defaultManager];
NSString *dir = @"NSFileManagerTestDir";
NSString *dirInDir = [@"TestDirectory" stringByAppendingPathComponent: @"WithinDirectory"];
NSString *str1,*str2;
PASS(mgr != nil && [mgr isKindOfClass: [NSFileManager class]],
"NSFileManager understands +defaultManager");
@ -135,6 +136,24 @@ NSLog(@"'%@', '%@'", NSUserName(), [attr fileOwnerAccountName]);
PASS([mgr changeCurrentDirectoryPath: @"subdir"],
"NSFileManager can move into subdir");
{
BOOL isDir;
PASS([mgr createDirectoryAtPath: dirInDir
withIntermediateDirectories: NO
attributes: nil
error: NULL] == NO,
"NSFileManager refuses to create non-existent intermediate directories withIntermediateDirectories == NO");
PASS([mgr createDirectoryAtPath: dirInDir
withIntermediateDirectories: YES
attributes: nil
error: NULL],
"NSFileManager can create intermediate directories withIntermediateDirectories == YES");
PASS([mgr fileExistsAtPath: dirInDir isDirectory: &isDir] && isDir == YES,
"NSFileManager create directory and intermediate directory that actually exist");
}
PASS_EXCEPTION([mgr removeFileAtPath: @"." handler: nil];,
NSInvalidArgumentException,