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

Re: [MacPerl] Invisible Test/psh



At 13.54 -0500 1998.11.24, strider corinth wrote:
>The question I have relates to invisible files, however. I looked into the
>toolbox function for file info including the invisible bit, and the type it
>returns is U16. I don't know what U16 is, or how to use it. Could someone
>give me a hand with that? (I need to use it in the ls function).

#!perl -wl
# invisible.plx
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