At 21:42 +0100 2001.02.26, Jan Erik Moström wrote:
>If I have understood things correctly I can't use -w or -W to determine if a
>file is locked or not. So I tried figuring out how to get info using the
>Mac::Files module and the FSpGetCatInfo function to get the information.
>
>According to the module info:
>
>U16 fdFlags  lags ex. hasbundle, invisible,locked, etc.
>
>But how do I get the locked flag etc. I tried different ways of writing this
>and looking at the source but it seems that I don't understand this (as usual
>8-) so if someone could point me to a short example I would be grateful.

Well, that does not actually mean "locked" in the sense of clicking the
"Locked" checkbox.  It means "you cannot change the name or icon".  Open
the file's info in ResEdit and you will see "Locked", "File Locked", and
"Resources Locked."  Locked is the one in fdFlags.  File Locked is the one
in the Finder Get Info checkbox.  Dunno what the other is.

Anyway, to get data out of the flags, you find out what the flag's bit is.
For example, with fdFlags, isStationery is bit 11.

#!perl -wl
# http://gemma.apple.com/techpubs/mac/Toolbox/Toolbox-464.html
use Mac::Files;
use constant isStationery => 1 << 11;

my $finfo = FSpGetFInfo("Bourque:bugrep.txt") or die $^E;
print $finfo->fdFlags;
print 'file is',
    ($finfo->fdFlags & isStationery ? ' ' : ' not '),
    'stationery.';


You can get whether or not a file or folder is locked not with FInfo, but
with CatInfo, using the ioFlAttrib field.  The 0 bit says if it is locked
or not.

#!perl -wl
# http://gemma.apple.com/techpubs/mac/Files/Files-118.html
use Mac::Files;
use constant fileLocked => 1 << 0;

my $catinfo = FSpGetCatInfo("Bourque:bugrep.txt") or die $^E;
print 'file is',
    ($catinfo->ioFlAttrib & fileLocked ? ' ' : ' not '),
    'locked.';

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to