是否有一种独立于平台的方法来检查文件路径是否是Haskell中根目录的某种表示?
在Haskell中,是否有一种便携式方法可以检查filepath
如果它是根目录,例如/
或// onix/posix/ linux和
c:\
或\\?\ unc \ foobar
在Windows/nt/dos上?我已经检查了Directory
和filepath
packages,但我找不到此功能。
In Haskell, is there a portable way to check of a FilePath
if it’s a root directory, e.g. /
or //
on Unix/POSIX/Linux, and C:\
or \\?\UNC\Foobar
on Windows/NT/DOS? I’ve checked through the directory
and filepath
packages but I can’t find a function for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在
base
中没有看到任何东西,但是似乎有filepath
声称使用GHC发货的库(实际上,即使在没有依赖关系的项目中,我也发现它可用)。它包含诸如 iSdrive :: filepath - >布尔 。它指出,在POSIX上,/
被认为是唯一的“驱动器”。此功能似乎表现得以您希望的方式(滚动到splitDrive
有关涉及UNC的示例)。I don't see anything in
base
, but there appears to be afilepath
library that claims to be shipped with GHC (and indeed I find it available even in a project with no dependencies). It contains functions such asisDrive :: FilePath -> Bool
. It notes that on POSIX,/
is considered the only "drive". This function appears to behave the way you hope (scroll up to the docs forsplitDrive
for examples involving UNC).