![](/img/trans.png)
[英]Path concat difference between std::filesystem and std::experimental::filesystem
[英]Why does std::experimental::filesystem::path not accept wildcards like “*”?
#include <string>
#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p("/usr/include/c++/../sys/*");
p = fs::canonical(p);
}
gcc 6.2.0编译正常,但运行时错误显示:
在抛出'std :: experimental :: filesystem :: v1 :: __ cxx11 :: filesystem_error'实例后调用终止
what():文件系统错误:无法规范化:没有这样的文件或目录[/usr/include/c++/../sys/*] [/ data / svn / yaoxinliu]已中止
为什么 std::experimental::filesystem::path
不接受 *
通配符 ?
根据文件
std::experimental::filesystem::canonical
将路径p转换为规范的绝对路径,即没有点,点点元素或符号链接的绝对路径。
由于std::experimental::filesystem::canonical
还必须取消引用包含在该路径中的符号链接,因此它只能接受现有文件或目录的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.