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


Subject: Re: [netatalk-admins] Type/Creator from Perl?
From: Neil McAllister (nmcallister@primo.com)
Date: Mon Oct 05 1998 - 14:25:47 EDT


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;

--
Neil McAllister, Systems Administrator
Primo Angeli Inc., San Francisco, CA, USA
http://www.primo.com  mailto:nmcallister@primo.com



This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:33:23 EST