[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Controlling File Visibility and Dialog for Getting a Folder Path



On Tue, Jul 06, 1999 at 01:50:07AM -0400, David Ackerman wrote:
> 
> $att = MacPerl::Pick('Mae the file:', ('visible', 'invisible'));
> if ($att eq 'visible') {
> 		$val = 256; #what my test file was set to at start
> 
> } else {
> 		$val = 16384; #icon is invisible in finder
> }

This looks like you're specifying a hard coded value for all the flags,
when you really just want to change one flag.  This will change visibility,
certainly, but it will also change the settings of other important flags.

The correct way to do this is to find out which bit specifies invisibility,
get the current value for the flags, use the bitwise operators to create a
new value with the invisibility flag set appropriately, and apply the new
value to the file.


I don't know which flag is invisibility (I'd assume there's a constant for
it somewhere in the MacPerl library), but your code might end up looking
something like this:


$att = MacPerl::Pick('Make the file:', ('visible', 'invisible'));
$pointer = StandardGetFile(0, -1);
if ($pointer->sfGood()) {
    open (IN, $pointer->sfFile()) || die($!);
    $cat_info = FSpGetCatInfo($pointer->sfFile()) || die($!);
    $fndr_info = $cat_info->ioFlFndrInfo();
    $flags = ($fndr_info->fdFlags());

    if ($att eq 'visible') {
        $flags &= ~ FI_INVISIBLE;   # make visible
    } else {
        $flags |=   FI_INVISIBLE;   # make invisible
    }

    $fndr_info->fdFlags($flags);
    $cat_info->ioFlFndrInfo($fndr_info);
    FSpSetCatInfo($pointer->sfFile(), $cat_info) || die($!);
    close (IN);
}


Where FI_INVISIBLE would be replaced with the proper way to specify the bit
for invisibility.


Ronald

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org