我如何在Haskell中列出磁盘驱动器? 我想在Windows上获取磁盘驱动器号,并在Linux上获取“/”。 可能吗? 我找不到任何地方。
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)
您可以尝试枚举所有26个可能的驱动器号,并使用System.Directory
doesDirectoryExist
来查看它们是否存在。 我相信会有效…