如何比较 c++ 中的(目录)路径?

发布于 12-21 04:37 字数 426 浏览 4 评论 0原文

我正在寻找一种方法来检查两个字符串在文件系统路径(目录)方面是否相同。例如,该组中的所有字符串在文件系统路径方面都是相同的:{/x,\x,//x,/x/},但这两个 - /x/y 不是,即使 /y 是符号链接到 /x。我要编写的程序应该既适用于 Linux,也适用于 Windows,所以我正在寻找便携式解决方案。

编辑:

我只使用boost的仅标头库,因此使用boost::filesystem的解决方案对我来说不合适。我知道Windows API中有UrlCompare,Linux中有类似的东西吗?

I'm looking for a way to check if 2 strings are the same in terms of filesystem path (directory). For example all string from this set are the same in terms of filesystem path: {/x,\x,//x,/x/}, but this two - /x and /y are not, even if /y is symbolic link to /x. The program I'm going to write should work as for Linux as well for windows, so I'm looking for portable solution.

EDIT:

I'm using only header-only libs of boost, so solution with boost::filesystem is not ok for me. I know that there is UrlCompare in windows API, is there something like in linux?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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