Subject: [netatalk-admins] Type/Creator from Perl?

From: Neil McAllister <[email-masked]>
Date: Mon, 5 Oct 1998 10:26:48 -0700

Can anyone think of the most efficient possible way of querying the file
type/creator of a netatalk file from within a Perl script?  I'm not real
familiar with the way netatalk stores this info.

--
Neil McAllister, Systems Administrator
Primo Angeli Inc., San Francisco, CA, USA
http://www.primo.com  mailto:[email-masked]

---

From: Neil McAllister <[email-masked]>
Date: Mon, 5 Oct 1998 11:25:47 -0700

How about this?  It seems to work for me... (kudos to some earlier
netatalk-admins I found that mentioned where to find the Type/Creator info
in the resource file).

I suppose to make it "proper" I would need to query an .AppleVolumes file
for any files I discover that do not have a netatalk resource file.

---------------------------[ cut here ]-------------------------------
#!/usr/bin/perl
#
#       Script to query the file type and creator of a file stored on a
#       netatalk server.  Syntax:  typecreator <filename>

use File::Basename;

$filename = shift @ARGV;

if (!($filename)) {  print "Usage: typecreator <filename>\n"; exit 1;  }
if (!(-e $filename)) {  print "Not found: $filename\n";  exit 1;  }

$qfilename = dirname($filename) . '/.AppleDouble/' . basename($filename);
if (!(-e $qfilename)) {
        print "netatalk resource file $qfilename does not exist.\n";
        exit 1;
}
open MYFILE, $qfilename;
seek MYFILE, 557, 0;
read MYFILE, $typecreator, 8;
close MYFILE;

print "Type: ", substr($typecreator, 0, 4), "   Creator: ";
print substr($typecreator,4,4), "\n";
exit 0;