Re: Lock a file in cocoa
Re: Lock a file in cocoa
- Subject: Re: Lock a file in cocoa
- From: Ken Thomases <email@hidden>
- Date: Fri, 19 Mar 2010 05:42:21 -0500
On Mar 19, 2010, at 4:59 AM, Nikhil Khandelwal wrote:
> Is there any way to lock a file in cocoa? I want to lock a file on desktop programmatically so that I can't move that file to trash until I unlock the file.
I recommend against doing that. Locking the file in this sense should probably be left in the user's domain.
That said, the lock that corresponds to the "Locked" checkbox in the Get Info window is represented in the APIs in a couple of different ways:
With NSFileManager, you can set the NSFileImmutable attribute for a file. See -setAttributes:ofItemAtPath:error: and -createFileAtPath:contents:attributes:.
In the chflags(2) system call, it is the UF_IMMUTABLE flag.
In the File Manager APIs, it's the kFSNodeLocked{Bit|Mask} in the nodeFlags of a FSCatalogInfo structure.
Cheers,
Ken
_______________________________________________
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