[Pythonmac-SIG] unlock a file?

Rob Managan managan@llnl.gov
Fri, 21 Apr 2000 11:21:04 -0700


At 2:03 PM -0400 4/21/00, Doug Wyatt wrote:
>Hi,
>
>I've been trying to find a way to unlock a Mac file from Python.
>
>Is there one, short of writing a module in C to call PBGetFInfo etc?
>
>Doug
>

Jack just mentioned about how to set the file info.
   import macfs, MACFS
   fss = macfs.FSSpec("thefile")
   finfo = fss.GetFInfo()
   finfo.Flags = finfo.Flags | MACFS.kIsInvisible
   fss.SetFInfo(finfo)

  One of the finder flags controls whether the file is locked or not. It is bit

kNameLocked = 0x1000

of that integer.

So you should be able to get the file info, change that bit and then 
set the file info. Not sure about telling the finder about the 
change. You can always close and open the folder to force an update.
-- 
*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-
Rob Managan       <mailto://managan@llnl.gov>
LLNL                      ph:  925-423-0903
P.O. Box 808, L-095       FAX: 925-422-3389
Livermore, CA  94551-0808