At 0:23 -0800 5/2/03, Rich Morin wrote:
I've come up with some peculiar questions about OSX file systems:

  *  How can I get the file length and size on disk for a file's Data
     and Resource forks?
You can access the data or resource fork of any file by appending "/..namedfork/data" or "/..namedfork/rsrc" to the file name (previous to 10.2 it was just /data and /rsrc I believe). So:

$file = '/Applications/Interarchy 6.1/Interarchy';

$dsize = (stat("$file/..namedfork/data"))[7];
$rsize = (stat("$file/..namedfork/rsrc"))[7];

print "$file $dsize $rsize\n";

  *  How can I get the "Kind" information (as reported by File Buddy,
     Get Info, and Super Get Info)?
I think this is just looked up based on the file type. You can get the file type via:

use Mac::Files;

$finfo = FSpGetFInfo( $file );
print $finfo->fdType,"\n";

  *  How can I get the contents of an alias?

ResolveAlias ALIAS
Resolves an alias. In scalar context, returns the path
to the resolved file. In list context, also returns
whether the alias was changed when resolving.

So

$path = ResolveAlias( $alias );

But $alias is an Alias, not an Alias File.

You can probably use Mac::Resources to open the alias file and read the alis=0 resource from the alias file.

I don't know about the rest of the unix/sticky bit/symlink issues.

Note that symlings and aliases are two very different things. An Alias is a Mac file with a resource fork and an alias handle in the resource fork (alis=0 resource) which can deal with the destination file moving and tracks it and is very robust. A symling is a unix file which essentially just has the path to another file stored in it's data fork, it is therefore very simple and quite fragile (which is sometimes good).

Enjoy,
Peter.

--
<http://www.interarchy.com/> <http://download.interarchy.com/>

Reply via email to