PDA

View Full Version : How to unlock a locked file


yogish
November 3rd, 2008, 03:52 AM
Hi,

I am trying to delete a files using remove(). But, the locked file fails in remove() .
I am looking for the api/function to unlock a locked file.
Does anyone knows how to unlock a locked file .

Thanks

Frida
November 9th, 2008, 02:21 AM
If you click once on the file and go to the File menu and select 'Get Info', under the 'General' setting in the info window there is a little tick box which says 'Locked'. Make sure it is not ticked, then delete the file by moving it to the trash and emptying it. You could also delete is by holding down the Alt/Option key when emptying the trash.

ElDiabloConCaca
November 9th, 2008, 08:56 AM
I think since this is posted in "Software Programming & Web Scripting" that the original poster is looking for a way to unlock a file via some programming API (as stated in the original post) -- not by directly manipulating the file with the Finder.

Frida
November 9th, 2008, 03:10 PM
I think since this is posted in "Software Programming & Web Scripting" that the original poster is looking for a way to unlock a file via some programming API (as stated in the original post) -- not by directly manipulating the file with the Finder.

Well, then it's above my head :(

Mikuro
November 18th, 2008, 05:52 AM
I'm not sure how to do it in straight C, but you can do it via AppleScript like this:tell application "Finder"
set the locked of file "Mac HD:path:to:file" to false
end tellOr if you want to use Unix-style paths instead of HFS-style paths, like this:tell application "Finder"
set the locked of file (posix file "/path/to/file") to false
end tell

You can also use the SetFile Terminal command:SetFile -l /path/to/file