checking removable drives

Ken Ray kray at sonsothunder.com
Wed Nov 2 22:59:02 EST 2005


On 11/2/05 7:43 PM, "Buster" <wouter.abraham at scarlet.be> wrote:

> Hi,
> 
> As you didn't mention which info you exactly need,
> this call can help you get the info of all devices for starter:
> 
> put  shell("diskutil list")

Yes, and after checking, you can do this:

on mouseUp
  put isRemovable("USB DISK")
end mouseUp

function isRemovable pDisk
  switch (the platform)
  case "MacOS"
    if isOSX() then
      put shell("diskutil list") into tData
      put lineOffset(" " & pDisk & " ",tData) into tLine
      put last word of line tLine of tData into tDisk
      put shell("diskutil info" && tDisk) into tDiskInfo
      put word 2 of line lineOffset("Ejectable:",tDiskInfo) of tDiskInfo =
"Yes" into tRetVal
    end if
    break
  case "Win32"
    break
  end switch
  return tRetVal
end isRemovable

function isOSX
  set the itemDel to "."
  return (item 1 of the systemVersion >=10)
end isOSX

Obviously this is only OSX, but one other thing to consider is that it took
a little over 2 seconds to run this function with the two calls to
'diskutil', so it is certainly not a speedy call...


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list