• 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 a file is Locked
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Checking if a file is Locked (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: Checking if a file is Locked
  • Next by Date: nsview anti-aliasing again
  • Previous by thread: Re: Checking if a file is Locked
  • Next by thread: exceptions, debug and deployment
  • Index(es):
    • Date
    • Thread