[Pythonmac-SIG] Method to lock/unlock files

Mike Nardell miken@inetworld.net
Thu, 25 Apr 2002 19:15:56 -0700


Jack --> Thank-you for your reply to my question:
> 
>> I would like to know if there is a method in Python to
>> unlock/lock files (so
>> they can be protected) on a Mac running on OS 8.6 or 9. Ideally
>> I would like
>> a cross platform solution. It seems that the calls to do things
>> like change
>> mode are not implemented in MacPython.

...excerpt of your reply:
> If you mean "protect from being written at
> all" (which, seeing your chmod reference may well be the case)
> that's a completely different ballpark. You want to look at the
> macfs module, in particular the FSSpec and FInfo objects.

This is in fact the issue at hand.

So I am trying to do something like this (I am testing this in Python
Interactive in the MacPython IDE):

>>> import macfs
>>> myFSSpec = macfs.FSSpec ("someTestFile")
>>> myInfo = myFSSpec.GetFInfo()
>>> myInfo.Flags
256

Now, the fact that I am clueless as to what 256 means, should tell me that I
need to read _Inside Macintosh: Files_. What makes me a bit confused is that
this Flags field remains unchanged after I have gone in and (using the File
Info DB ) changed the file from being unlocked to locked. Of course I
re-instanciate the FSSpec and FInfo objects by repeating the above commands.

Perhaps I am looking at the wrong field of the FInfo obj. How far off am I?

Regards,

Michael Nardell