• 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: 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

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

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