• 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: Only allowing a file to be opened by one app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Only allowing a file to be opened by one app


  • Subject: Re: Only allowing a file to be opened by one app
  • From: Michael Ash <email@hidden>
  • Date: Wed, 1 Jul 2009 18:54:16 -0400

On Wed, Jul 1, 2009 at 11:47 AM, Andy Bettis<email@hidden> wrote:
> Hi,
>
> I'd like to set up my app so that if one user has a file open with it
> another user cannot open the file. This only needs to limit access by copies
> of my app, no need to block out any other process.
>
> In the past I'd just leave a write access path open when the file was opened
> from within my app - this would prevent anyone else from getting write
> access (and therefore opening the file) and has the bonus that if the app
> was closed down unexpectedly (these things happen) then the 'lock' was
> removed. This doesn't happen with default NSDocument based apps (like mine)
> - is there a way of doing it? Or a better way of setting exclusive access?
>
> Any help gratefully appreciated.

How about calling open() with the O_EXLOCK flag, or using the flock()
call on your document file?

Mike
_______________________________________________

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: 
 >Only allowing a file to be opened by one app (From: Andy Bettis <email@hidden>)

  • Prev by Date: Re: [NSImageView setImage:theImage] Thread safe??
  • Next by Date: Re: libSystem.B.dylib
  • Previous by thread: Only allowing a file to be opened by one app
  • Next by thread: Re: Only allowing a file to be opened by one app
  • Index(es):
    • Date
    • Thread