Haskell Drive List on Windows

How can I list drives in Haskell? I would like to get drive letters on Windows and only get "/" on Linux. Is it possible? I could not find anything.

+7
windows haskell
source share
2 answers
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) 
+4
source share

You can try simply listing all 26 possible drive letters and see if they exist with doesDirectoryExist from System.Directory . I believe this will work ...

+1
source share

All Articles