In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (John Delacour)
wrote:
> Without loading Mac::Carbon you can get (and set) type and creator
> with osascript in the shell, but it might be quicker (if milliseconds
> are important) just to print the data to an anonymous file and have
> NC read that, if it can.
Not sure why anyone would do that, since Mac::Carbon comes with the Mac, and
the call to GetPerlInfo() is much simpler to use, and executes much faster.
$ time perl -MMacPerl=:all -e 'print join "|", GetFileInfo(shift)' file
R*ch|TEXT
real 0m0.197s
user 0m0.091s
sys 0m0.030s
$ time perl -e '$file = shift; print `osascript -e '\''tell app "Finder" to
get {file type, creator type} of (posix file "$file")'\''`' file
TEXT, R*ch
real 0m0.523s
user 0m0.196s
sys 0m0.112s
Perhaps you didn't think it would be so fast because you thought one had to
load ALL of Mac::Carbon? The MacPerl module itself is very small. But,
even the bigger modules load really fast on Mac OS X these days.
Loading/importing the entire distribution -- Speech, Sound, InternetConfig,
OSA, AppleEvents, Notification, Process, Resources, and so on -- on my
PowerBook G4/1GHz:
$ time perl -MMac::Carbon -e1
real 0m0.938s
user 0m0.570s
sys 0m0.093s
Of course, Mac::Carbon does not work on Intel systems ... not for another
couple of weeks anyway.
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Technology Group [EMAIL PROTECTED] http://ostg.com/