是否有一种独立于平台的方法来检查文件路径是否是Haskell中根目录的某种表示?

发布于 2025-02-07 20:22:39 字数 271 浏览 0 评论 0原文

在Haskell中,是否有一种便携式方法可以检查filepath如果它是根目录,例如/// onix/posix/ linux和c:\\\?\ unc \ foobar在Windows/nt/dos上?我已经检查了Directoryfilepath 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻风 2025-02-14 20:22:39

我在base中没有看到任何东西,但是似乎有 filepath 声称使用GHC发货的库(实际上,即使在没有依赖关系的项目中,我也发现它可用)。它包含诸如 iSdrive :: filepath - >布尔 。它指出,在POSIX上,/被认为是唯一的“驱动器”。此功能似乎表现得以您希望的方式(滚动到 splitDrive 有关涉及UNC的示例)。

I don't see anything in base, but there appears to be a filepath 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 as isDrive :: 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 for splitDrive for examples involving UNC).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文