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

Re: [MacPerl] Help with 'Hidden' files/directories



At 10.25 -0400 1998.09.16, Aiken, Greg wrote:
>a) how to make a Mac file or directory become 'invisible' to the desktop,
>and b) how to make the 'invisible' file or directory become visible
>again?

The subs return 0 if it is an invisible file and you want to make it
invisible, or a visible file you want to make visible.  Otherwise, it
returns the new flag.  I don't know if this is the best way, but oh well.
If you run is_visible, you don't really need to check the return of
make_{in}visible, and likewise, if you check the sub return of
make_{in}visible, you don't need to use is_visible.  Of course, that does
not take into account the fact that its flags could change in between your
checking the flags and your setting the flags, but c'est la vie.

#!perl -wl
use Mac::Files;
use strict;
use constant fInvisible => 16384;
my($file, $finfo, $flags);

$file = FindFolder(kOnSystemDisk, kDesktopFolderType) . ':test';
$finfo = FSpGetFInfo($file);
$flags = $finfo->fdFlags;

$flags = is_visible($flags)
  ? make_invisible($flags)
  : make_visible($flags);

if ($flags) {
  $finfo->fdFlags($flags);
  FSpSetFInfo($file, $finfo);
}


sub is_visible {return ((shift() & fInvisible) ? 0 : 1)}

sub make_visible {
  my $flags = shift;
  return (($flags & fInvisible) ? $flags ^ fInvisible : 0)
}

sub make_invisible {
  my $flags = shift;
  return (($flags & fInvisible) ? 0 : $flags | fInvisible)
}

__END__

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch