[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

re: [MacPerl] Getting size of resource forks



charles@jolt.mpx.com.au (Charles Cave) wrote:
} In the process of learning MacPerl by studying Larry Wall's
} book, I wrote a recursive program to print a directory listing
} with Creator, Type and Size.
} 
} I found that applications and resource files return 0 bytes!
} How can I get the total size of any file - applications,
} resource files, aliases, the Desktop and Icons.

The easiest way is to ask the Finder:

#!/usr/local/bin/perl

$file = "Macintosh HD:SimpleText";
$tsize = MacPerl::DoAppleScript(<<ENDIT);
tell application "Finder"
        size of alias "$file"
end tell
ENDIT
$size = -s $file;
print "$tsize, $size\n";

which returned

58768, 0

Of course, since it used AppleScript, it was slower than molasses.

} 
} ------------------------------------------------------
} Charles Cave
} Sydney, Australia
} Email: charles@jolt.mpx.com.au
} URL:   http://www.ozemail.com.au/~caveman
} ------------------------------------------------------
} 
} 
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us