On 29 Oct 2012, at 09:22, Andreas Grosam <agro...@onlinehome.de> wrote:
> I'm attempting to create a directory with NSFileManager's method. The > directory may already exist. > > According the documentation > <https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html> > the method shall return YES if the directory already exists: > > " > Return Value > YES if the directory was created or already exists or NO if an error occurred. > " > > However, when the directory already exists it returns NO with error parameter > set: > > > NSFileManager* fm = [[NSFileManager alloc] init]; > NSString* tmpDir = [NSTemporaryDirectory() > stringByAppendingPathComponent:@"Test"]; > NSError* error; > if (![fm createDirectoryAtPath:tmpDir > withIntermediateDirectories:NO > attributes:nil > error:&error]) { > NSLog(@"ERROR: setup test environment with error: %@", error); > } > > > > Console: > > ERROR: setup test environment with error: Error Domain=NSCocoaErrorDomain > Code=516 "The file “Test” couldn’t be saved in the folder “T” because a file > with the same name already exists." UserInfo=0x100600150 > {NSFilePath=/var/folders/m9/5p__qm3967qchc9_26tl85km0000gn/T/Test, > NSUnderlyingError=0x100602d00 "The operation couldn’t be completed. File > exists"} > > > Do I miss something? Is it possible you've ended up with a *file* there named "Test" rather than a directory? _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com