• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists


  • Subject: Re: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists
  • From: Mike Abdullah <email@hidden>
  • Date: Mon, 29 Oct 2012 11:43:36 +0000

On 29 Oct 2012, at 09:22, Andreas Grosam <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists
      • From: Andreas Grosam <email@hidden>
References: 
 >createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: ARC question
  • Next by Date: Re: ARC question
  • Previous by thread: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists
  • Next by thread: Re: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists
  • Index(es):
    • Date
    • Thread