I've only just run across this as a potential solution to a prospective need, but might Kernel Authorizations be what you need?
https://developer.apple.com/library/mac/technotes/tn2127/_index.html -- Gary L. Wade (Sent from my iPhone) http://www.garywade.com/ > On May 22, 2014, at 9:21 AM, Jens Alfke <[email protected]> wrote: > > >> On May 22, 2014, at 8:51 AM, Matthew LeRoy <[email protected]> wrote: >> >> Does anyone have any idea if there is a way to get the document architecture >> to lock a document file when it is opened? > > If you implement the lower-level read/write methods in NSDocument, you have > full control over opening and closing the file. You can then make whatever > filesystem calls you want to lock/unlock it. > >> When I say “lock”, I’m talking about an exclusive file lock at the >> filesystem level, as in no other user or process can open, move, or delete >> the file. > > There’s no such thing in standard Unix. The closest thing is “advisory” locks > (i.e. flock(2)), which are opt-in and can be ignored, and only prevent > modifying the file, not opening/moving/deleting it. > > HFS+ does have extended attributes that, I _think_ include some sort of > “immutable” option, but from what you say below I don’t think that’s relevant > here. > >> This causes all kinds of kooky and undesired behavior if a document on a >> remote filesystem is first opened in the Mac version (which does not lock >> the file), then opened concurrently by the Windows version (which locks the >> file). > > OK, here it gets even messier, because you’re talking about locking files on > a file server. This involves the semantics of the file sharing protocol (you > didn’t specify what it is), of OS X’s client implementation of that protocol, > and of the underlying filesystem of the disk volume being shared. There are > significant differences between the behavior of NFS, AFP and SMB, and between > different versions of those, and different versions of OS X connecting to > them … it’s quite a rat-hole. I’ve seen people give vehement advice to > _never_ use SQLite databases on shared volumes, for example, because problems > with file locking can easily cause database corruption. > > At a minimum you’re going to need to describe exactly what software is > involved on both sides, and what file server protocol is in use. > > —Jens _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
