Ejecting An Image Disk
Ejecting An Image Disk
- Subject: Ejecting An Image Disk
- From: Luther Fuller <email@hidden>
- Date: Tue, 28 Oct 2008 12:42:51 -0500
In the script below, both the run handler and the open handler do the
same thing, they call the ejectImageDisk handler. They both work
correctly. Except ...
Notice the execution times in the lines marked with <<<<<<<. When
called from run, the disk is almost instantly ejected, but when called
from open, there is a very long delay until ejection. That shouldn't be!
Does anyone have an explanation?
on run
try
set itemAlias to choose file
-- choose only .sparseimage, .sparsebundle, or .dmg file
on error errText number errNr
beep
return
end try
--
set mountPoint to my getMountPoint(itemAlias)
--
if mountPoint ≠ "" then
set startTime to (current date)
my ejectImageDisk(mountPoint)
(current date) - startTime
display dialog "Run " & the result -- 2 seconds <<<<<<<<<<<<<<<
else
beep
end if
end run ---------------------------------
on open dropList
if (count items of dropList) > 1 then
tell application "Finder" to beep
return
end if
set imageAlias to (item 1 of dropList) as alias
tell application "Finder"
if (name extension of imageAlias) is not in {"dmg", "sparseimage",
"sparsebundle"} then
error "Not a disk image file."
end if
--
set mountPoint to my getMountPoint(imageAlias)
--
if mountPoint ≠ "" then
set startTime to (current date)
my ejectImageDisk(mountPoint)
(current date) - startTime
display dialog "Run " & the result -- 17 seconds <<<<<<<<<<<<<
end if
end tell
end open -------------------------------
on ejectImageDisk(mountPoint)
do shell script "hdiutil detach " & mountPoint & " -force"
end ejectImageDisk ----------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden