• 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: Lock a file in cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Lock a file in cocoa (From: Nikhil Khandelwal <email@hidden>)

  • Prev by Date: Lock a file in cocoa
  • Next by Date: Re: Lock a file in cocoa
  • Previous by thread: Lock a file in cocoa
  • Next by thread: Re: Lock a file in cocoa
  • Index(es):
    • Date
    • Thread