如何比较 c++ 中的(目录)路径?
我正在寻找一种方法来检查两个字符串在文件系统路径(目录)方面是否相同。例如,该组中的所有字符串在文件系统路径方面都是相同的:{/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 技术交流群。
