• 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: Check ability to write to nonexistent directory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check ability to write to nonexistent directory


  • Subject: Re: Check ability to write to nonexistent directory
  • From: Alastair Houghton <email@hidden>
  • Date: Fri, 18 Jan 2008 17:29:10 +0000

On 18 Jan 2008, at 17:11, Mitchell Livingston wrote:

I would like to be able to use a function similar to NSFileManager's isWritableFileAtPath: to determine if I can write to a certain directory, but in this case the folder might not exist yet. For example, a Download folder in Documents might not exist, but i would like to be able to pass in the path and see 1. if it does exist, can I write to it/read from it? 2. if it doesn't exist, can if be created, and then can I write to it? Is there a function for this?


There are certainly functions you can use, but it's generally best just to try writing to it and only then start trying to handle the situation where you can't. Why? Because on a multitasking system like Mac OS X, some other program could create, delete or modify the folder you're trying to save to between your tests and your actual write. In the worst case, this can actually create a security hole, since it might be used by another user to cause a more privileged user to write to the wrong place, with potentially catastrophic consequences.

Ideally, the only time you should be examining folders like this is where you're just using the information for display purposes. e.g. Finder's indication as to whether a folder is write-able or not.

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

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


References: 
 >Check ability to write to nonexistent directory (From: Mitchell Livingston <email@hidden>)

  • Prev by Date: Re: Force NSOpenPanel's -panel:shouldShowFilename: to get called again?
  • Next by Date: Cursor duplication problem
  • Previous by thread: Check ability to write to nonexistent directory
  • Next by thread: Cursor duplication problem
  • Index(es):
    • Date
    • Thread