On Wed, Jul 1, 2009 at 11:47 AM, Andy Bettis<a...@andybettis.com> 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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com