Re: Checking if a file is Locked
Re: Checking if a file is Locked
- Subject: Re: Checking if a file is Locked
- From: Deric Horn <email@hidden>
- Date: Wed, 29 Nov 2006 09:46:30 -0800
- Thread-topic: Checking if a file is Locked
A file can be locked in a variety of ways from ACLs, standard Unix
permissions, the Finder locked bit, it may reside on read only media, or as
Sean pointed out, may be locked between the time you check and open the
file.
I usually recommend that you just try to open the file for writing, and then
deal with the error conditions.
Deric Horn
Mac OS X Application Frameworks Evangelist
Apple Worldwide Developer Relations
email@hidden
> On 2006-11-28 22:08, Chad Armstrong said:
>
>> Is there a way to check if a file is locked? I would preferably like
>> to be able to check using Cocoa, but if there is a Carbon or UNIX way
>> for checking, that would work, as well.
>
> Be careful how you use this info though. If you do something like:
>
> BOOL isFileLocked = blah blah
> if (isFileLocked == NO) {
> write to file
> }
>
> Then some other process could change the lock state between your check
> and your write. Then your write can fail anyway.
>
> --
> ____________________________________________________________
> 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)
>
> 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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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