on mountImageDisk(imageFileAlias)
-- imageFileAlias is an alias to the Mail-Safe sparsebundle file
-- returns an alias to the disk mounted from imageFileAlias
tell application "Finder" to open imageFileAlias
--
set found to false
set imageFileText to (imageFileAlias as text)
repeat 20 times
delay 1
set imageInfo to (do shell script "hdiutil info -plist ")
tell application "System Events"
set infoRecord to value of (make property list item with properties {text:imageInfo})
end tell
set imagesList to (get images of infoRecord)
repeat with n from 1 to (count items of imagesList)
set imagesItem to (item n of imagesList)
set imagePath to (get |image-path| of imagesItem)
set imagePath to (POSIX file imagePath) as alias as text
if imagePath = imageFileText then
set systemEntities to (|system-entities| of imagesItem)
repeat with k from (count items of systemEntities) to 1 by -1
try
set volName to (|mount-point| of (item k of systemEntities))
set found to true
exit repeat
end try
end repeat
exit repeat
end if
end repeat
if found then exit repeat
end repeat
if not found then error "Unable to mount the image disk."
set diskAlias to (POSIX file volName) as alias
return diskAlias -- an alias to the disk mounted from the disk image file
end mountImageDisk ------------------------------------------------------