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

Re: [MacPerl] UnmountVol?



Chris Nandor writes 10 February 98

>You can use Apple Events.  This will not unmount a local hard drive; I
>think the Finder rejects the request because it requires user confirmation.
>But it will unmount removable media and shared volumes.
>
>#!perl -wl
>use Mac::AppleEvents;
>use Mac::Files;
>
>$disk = NewAliasMinimal('Extrasa:');
>$obj1 = "obj {want:type(cdis), from:null(), form:enum(indx), seld:alis(\@\@)}";
>$obj2 = "obj {want:type(prop), from:null(), form:enum(prop), seld:type(trsh)}";
>
>$evt = AEBuildAppleEvent('core', 'move', 'sign', 'MACS', 0, 0,
>  "'----':$obj1, insh:$obj2", $disk
>) or die ($^E);
>$rep = AESend($evt, kAEWaitReply()) or die ($^E);
>
>AEDisposeDesc($evt);
>AEDisposeDesc($rep);

Somewhat simpler is...

#!perl
use Mac::AppleEvents;
use Mac::Files;

$alias = NewAliasMinimal("theVolume:");

$evt = AEBuildAppleEvent('fndr', 'ptwy', 'sign', 'MACS', 0, 0,
"'----':alis(\@\@)", $alias) or die $^E;

$rep = AESend($evt, kAEWaitReply) or die $^E;

AEDisposeDesc $evt;
AEDisposeDesc $rep;

...but are there any drawbacks with this I wonder?

Alan Fry



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch