Re: Lock a file in cocoa
Re: Lock a file in cocoa
- Subject: Re: Lock a file in cocoa
- From: Ron Fleckner <email@hidden>
- Date: Fri, 19 Mar 2010 21:40:01 +1100
On 19/03/2010, at 8:59 PM, Nikhil Khandelwal wrote:
Hi,
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.
Thanks,
Nikhil
Hi Nikhil,
here's how I do it:
NSFileManager *fm = [NSFileManager defaultManager];
NSDictionary *attribs = [NSDictionary dictionaryWithObject:[NSNumber
numberWithBool:YES] forKey:NSFileImmutable];
[fm changeFileAttributes:attribs atPath:path];
Have a look at the NSFileManager Class Reference in the documentation.
Ron
_______________________________________________
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