• 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: checking if directory is writable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking if directory is writable


  • Subject: Re: checking if directory is writable
  • From: Tony Arnold <email@hidden>
  • Date: Tue, 10 Jan 2012 20:39:34 +1100

Hi Rick,

On 10/01/2012, at 7:49 PM, Rick C. wrote:

> Just looking for confirmation, I can use NSFileManager isWritableAtPath: if I want to check if a directory can be written to correct?  Or do I have to use attributesOfItemAtPath:error:?  I don't need to change permissions just to see if it's writable.  Thanks!

I was of the understanding that Apple's recommendation was just to try the operation you wanted to perform, and handle the error if there is one. This is taken from the NSFileManager header, directly above the isWriteableAtPath: declaration:

"The following methods are of limited utility. Attempting to predicate behavior based on the current state of the filesystem or a particular file on the filesystem is encouraging odd behavior in the face of filesystem race conditions. It's far better to attempt an operation (like loading a file or creating a directory) and handle the error gracefully than it is to try to figure out ahead of time whether the operation will succeed."

(Sorry for the resend — my original reply only went to Rick, not the entire list)

all the best,


Tony




----------
Tony Arnold
http://thecocoabots.com/

_______________________________________________

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: checking if directory is writable
      • From: Kyle Sluder <email@hidden>
    • Re: checking if directory is writable
      • From: Wade Tregaskis <email@hidden>
References: 
 >checking if directory is writable (From: "Rick C." <email@hidden>)

  • Prev by Date: Re: Forcing autosave
  • Next by Date: Messed up UTIs in NSDocument-based application
  • Previous by thread: Re: checking if directory is writable
  • Next by thread: Re: checking if directory is writable
  • Index(es):
    • Date
    • Thread