-- Gregg Podnar 

function FinderListDisks
  put "tell application" && quote & "Finder" & quote & return after scriptVar
  put "try" & return after scriptVar
  put "name of every folder of folder" && unwindPath(path) & return after scriptVar
  put "on error errmsg" & return after scriptVar
  put "return errmsg" & return after scriptVar
  put "end try" & return after scriptVar
  put "end tell" & return after scriptVar
  do scriptVar as AppleScript
  return unwindList(the result)
end FinderListDisks

-- This routine is to circumvent an AppleScript issue when accessing files rapidly.
-- AppleScript takes a very long time (even to timeout) if given a traditional path
-- especially during a call initiated by a "mouseDown".

function unwindPath p
  if (last char of p is ":") then delete last char of p -- preserve spaces and error-causing strings
  put "" into r
  repeat while (length(p) > 0) and (p contains ":")
    repeat with i = length(p) down to 1
      if char i of p is ":"
      then
        put i into pp
        exit repeat
      end if
    end repeat
    put quote & (char pp + 1 to length(p) of p) & quote after r
    delete       char pp     to length(p) of p
    put " of container " after r
  end repeat
  if p <> "" then put quote & p & quote after r --- last token
  return r
end unwindPath

function unwindList l -- for what AppleScript returns
  delete char offset("{",l) of l
  delete char offset("}",l) of l
  if offset(",",l) = 0 -- no commas ... one or fewer files 
  then 
    return stripQuote(l)
  else
    repeat with i = 1 to (number of items in l) - 1
      put return into char offset(",",l) of l -- return delimit
    end repeat
    repeat with i = 1 to number of lines in l
      put stripQuote(line i of l) into line i of l
    end repeat
    return l
  end if
end unwindList

function stripQuote string
  repeat while char 1 of string = " "
    delete char 1 of string
  end repeat
  if char 1 of string = quote then delete char 1 of string
  repeat while last char of string = " "
    delete last char of string
  end repeat
  if last char of string = quote then delete last char of string
  return string
end stripQuote