• 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: Sean McBride <email@hidden>
  • Date: Tue, 30 Oct 2012 13:39:17 -0400
  • Organization: Rogue Research Inc.

On Mon, 29 Oct 2012 10:22:57 +0100, Andreas Grosam said:

>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:

Strange.  I filed <rdar://9453805> last year about the docs for that method:

-------------
17-May-2011 02:25 PM Sean McBride:
The developer documentation for NSFileManager's createDirectoryAtPath:withIntermediateDirectories:attributes:error: says:

Parameters
path
The path at which to create the new directory. The directory to be created must not yet exist.

...

Return Value
YES if the operation was successful or already exists, otherwise NO.


I believe the sentence "The directory to be created must not yet exist." should be stricken.  It conflicts with what's implied by the return value. Also, in practice, passing an existent path works as expected (YES is returned).

09-Mar-2012 02:31 PM Sean McBride:
This is fixed in Xcode 4F90's built-in docs.

This issue has been verified as resolved and can be closed.
-------------

Note that in my experience YES is returned if the directory exists.

Do you require 10.7?  If so, try the URL version: createDirectoryAtURL:withIntermediateDirectories:attributes:error:.

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada



_______________________________________________

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: Quincey Morris <email@hidden>
References: 
 >createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists (From: Andreas Grosam <email@hidden>)

  • Prev by Date: CALayer still has no constraints on iOS
  • Next by Date: Re: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists
  • Previous by thread: Re: 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