At Fri, 14 Jul 2000 01:26:04 -0400, Eric Siegerman <[EMAIL PROTECTED]> wrote:
>> I'm not sure whether the compilers can be persuaded to
>> dereferense those links.
>
>Almost certainly not on Windows. On the Mac, probably. A MacOS
>alias is a weird beast, somewhere between symlink and hard link
>in behaviour, depending on circumstances (the algorithm for
>resolving one is pretty scary!) But it's implemented at a lower
>level than the GUI, if I recall, which is the salient detail
>here.
It's a simple call to ResolveAlias() to get what the alias points to. In
MacPerl, it is the same as it is on Unix:
#!perl -wl
my($file, %fseen);
$file = 'Some:Alias:File';
while (-l ($file = readlink $file)) {
die "Circular!" if $fseen{$file}++;
}
print $file;
__END__
To use the Mac OS API, though, it is just slightly more complex (using the
same basic Perl code here, but getting the alias data):
#!perl -wl
use Mac::Files;
use Mac::Resources;
my($file, %fseen);
$file = 'Some:Alias:File';
while (-l $file) {
my $rfd = OpenResFile($file) or die $^E;
my $handle = Get1Resource('alis', 0) or die $^E;
$file = ResolveAlias $handle;
CloseResFile $rfd;
die "Circular!" if $fseen{$file}++;
}
print $file;
__END__
Anyway, most programs will resolve the alias for you, so you don't even
need to think about it.
--
Chris Nandor | [EMAIL PROTECTED] | http://pudge.net/
Andover.Net | [EMAIL PROTECTED] | http://slashcode.com/