Determining read-only status of a file/folder (isWritableFileAtPath)?

  • Hi,

    My app uses a project-based format - really just a folder full of files but with an extension so that it looks like a regular file. As such, when a project is opened, the main project file is opened by the app (kind of like the .xcodeproj file in Xcode) and other files inside the package are opened as needed. Because of this, and because my app has an auto-save feature, my app doesn't support the opening of read-only projects, or of projects that are stored in non-writable locations.

    Thus, if the user tries to open a project from a non-writable location, my program just spews a message saying that it doesn't support read-only files and gives the user a hint about what to do.

    I'm using NSFileManager's -isWritableFileAtPath: to check this. I check the package folder itself, and also the main project file inside. If the file manager returns one or both as not being writable, the user gets the message.

    For the most part, this works fine. However, occasionally I get users reporting to me that they have received this message when they shouldn't - often, for instance, when the project is stored on an external drive (which is nonetheless writable) or when they are accessing it over a network.

    The docs don't really explain the exact circumstances in which -isWritableFileAtPath: returns NO. So, my question is, is NSFileManager the best way of doing this, or is there a better way? (Please don't tell me off for not supporting read-only projects. :) I hope to do so in a future version...)

    All the best,

    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
previous month october 2007 next month
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today