Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing appledouble format file for getting finder info

Status
Not open for further replies.

rk0000

Technical User
Mar 15, 2002
33
IN
Hi,
I am using MAC OS X. I have perl loaded in my machine. I have a appledouble format file(.adf). I want to parse this file to get the finder info. How to do this in perl script?
Thanks
Rk
 
I have written the following perl script:
#!/usr/bin/perl
use Mac::AppleSingleDouble;
     $foo = new Mac::AppleSingleDouble(shift);
     $finder_info = $foo->get_finder_info();
     print "The file Type is: $finder_info->{'Type'}\n";
     print "The file Creator is: $finder_info->{'Creator'}\n";
     print "The Finder label color is: $finder_info->{'LabelColor'}\n";
 $foo->close();
It is working fine. But i want created time and modified time also. what should i do?
Rk
 
Look at the stat function which should read the details from the file structure

HTH
--Paul
 
i tried
 $foo->get_entry(8)
print  " entry is : $foo->dump_entries()\n";
It is printing as
Mac::AppleSingleDouble=HASH(0x6590)->dump_entries()
I am new to perl. Am i using wrong sytax? tried with stat()function also. I think we have to pass the file handle for it.
i did the following:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blks)= stat($foo);
print "$ctime\n";
$foo->close();
Is this passing of $foo to stat is right? then why it is not printing the ctime?
thanks and regards
Rk
 
use the full path to the file, and stat should be ok
Code:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blks)= stat "path/to/$foo";
HTH
--Paul
 
Actually i have to get the Mac file information(dates). When i use the stat(), i am getting the input file info.
i added a line
$file = $ARGV[0]; in the begining
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blks)= stat($file);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)= localtime($mtime);
$year= 1900 + $year;
$mon = 1 + $mon;
 print  "year is : $year\n";
 print "month is : $mon\n";
 print "day is $mday\n";
It is giving the iput file info rather the actual Mac file. I think i have get the info  for entry 10 ( the documentation says entry 10 - Mac file info).
how to do this by get_entry(10)?
thanks
rk
 
OS X is basically a unix flavour AFAIK, are you passing the path to the file. If the file you're looking information on is always going to be in the same directory (not cgi-bin) you can prepend it

Code:
#!usr/bin/perl
$file="/home/rk0000/$ARGV[0]";
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blks)= stat($file);
(@date)=localtime(mtime);
$date[5]+=1900;$date[4]++;
print "Date of file $file is \t ".sprintf("%0.4d-%0.2d-%0.2d",$date[5],$date[4],$date[3]);
HTH
--Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top