Finding the name of a USB volume

tsj tsj at unimelb.edu.au
Wed Jan 6 21:19:28 EST 2010


On 7/01/10 12:50 PM, "Phil Davis" <revdev at pdslabs.net> wrote:

> On 1/6/10 3:31 PM, Richard Gaskin wrote:
>> tsj wrote:
>>> Richard - I haven't got an unnamed USB drive handy to test this with but
>>> what does the volumes function return when one is mounted? Does this
>>> give
>>> you the expected "untitled" (or "untitled 1" etc)?
>>> 
>>> If so, you could iterate through the listed volumes using a couple of
>>> applescripts to determine whether the drive was local (false if it's a
>>> network drive) ejectable (false if it's internal) and then if you get
>>> two
>>> false results you can attempt to open a file on the volume. If that
>>> gives
>>> you an error then the drive is write protected. If it passes all
>>> tests then
>>> you're left (presumably) with an external USB or Firewire drive.
> 
> The "passes all tests" list can also includes mounted .dmg files.

True - but only if it's modifiable (if not, trying to open a file for
writing will give you a "can't open file" error in the result). One other
test you can throw in is to get the format of the disk. DMGs appear to
always return 'Mac OS Extended format' while USB sticks *may* be in another
format (mine all appear to be MS-DOS (FAT32), which returns 'unkown format'
from applescript).
> 
> Thanks for posting this - very helpful.

Cheers,

Terry...




More information about the use-livecode mailing list