List of Mac OS X Volumes within Director

Sometimes you’ll need to find out the connected Volumes on OS X within your Director Application (e.g. to check if a specific CD is inserted). The BuddyAPI Xtra is not much of a help (but it will find all Volumes on a PC). So: How to do it?

Valentin Schmidt created the wonderful shellXtra, which connects your Application with an OS X Shell. If you are familiar with Shell programming, it will allow you things to do you never imagined! It’s for free and very easy to operate.

The following routine will browse through your Volumes and check for a specific file. It uses a combination of ShellXtra and BuddyAPI:

—-
— shell_cmd_list(„ls /Volumes/“)
— returns a list of all Volumes mounted!
—-
theVols = shell_cmd_list(„ls /Volumes/“)
noVol = 1
repeat with x = 1 to theVols.count
if baFileExists(theVols[x] & „:yourFile“) then
noVol = 0
exit repeat
end if
end repeat
if noVol = 1 then
— no Volume found
else
— Volume found
end if

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.