7

How can I list disk drives in Haskell? I would like to get disk drive letters on Windows and get just "/" on Linux. Is it possible? I couldn't find it anywhere.

Kara
  • 6,115
  • 16
  • 50
  • 57
remdezx
  • 2,939
  • 28
  • 49

2 Answers2

4
import System.Process
c = do
  res <- readProcess "wmic" ["logicaldisk","get","caption"] ""
  --print res
  -- clean up the output
  print $ init $ map (take 2) $ drop 1(lines res)
ja.
  • 4,245
  • 20
  • 22
1

You could try just enumerating all 26 possible drive letters and seeing if they exist using doesDirectoryExist from System.Directory. I believe that would work...

MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220