mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Fix directory creation to match actual OSX sematics as determined by adding
a few testcases ... The basic method should fail if the directory already exists. The intermediate directories method should fail if the directory exists unless the option to create intermediate directories is selected, in which case a pre-existing directory is counted as a success.
This commit is contained in:
parent
c494785630
commit
24d29934cf
4 changed files with 42 additions and 20 deletions
|
@ -40,6 +40,18 @@ int main()
|
|||
PASS([mgr fileExistsAtPath: dir isDirectory: &isDir] &&
|
||||
isDir == YES,
|
||||
"exists and is a directory");
|
||||
PASS(NO == [mgr createDirectoryAtPath: dir attributes: nil],
|
||||
"-createDirectoryAtPath:attributes: fails for existing directory");
|
||||
PASS(NO == [mgr createDirectoryAtPath: dir withIntermediateDirectories: NO
|
||||
attributes: nil error: 0],
|
||||
"-createDirectoryAtPath:withIntermediateDirectories:attributes:error:"
|
||||
" fails for existing directory if flag is NO");
|
||||
|
||||
PASS(YES == [mgr createDirectoryAtPath: dir withIntermediateDirectories: YES
|
||||
attributes: nil error: 0],
|
||||
"-createDirectoryAtPath:withIntermediateDirectories:attributes:error:"
|
||||
" succeeds for existing directory if flag is YES");
|
||||
|
||||
PASS([mgr fileAttributesAtPath: dir traverseLink: NO] != nil,
|
||||
"NSFileManager returns non-nil for attributes of existing file");
|
||||
attr = [mgr fileAttributesAtPath: dir traverseLink: NO];
|
||||
|
@ -47,7 +59,7 @@ int main()
|
|||
"NSFileManager returns non-nil for attributes of existing file");
|
||||
PASS([NSUserName() isEqual: [attr fileOwnerAccountName]],
|
||||
"newly created file is owned by current user");
|
||||
NSLog(@"'%@', '%@'", NSUserName(), [attr fileOwnerAccountName]);
|
||||
//NSLog(@"'%@', '%@'", NSUserName(), [attr fileOwnerAccountName]);
|
||||
err = (id)(void*)42;
|
||||
attr = [mgr attributesOfItemAtPath: dir error: &err];
|
||||
PASS(attr != nil && err == (id)(void*)42,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue