当我启动这段代码时,它说每个文件都是常规的,甚至是符号链接(symbolic link):
cout<<boost::filesystem::is_symlink(boost::filesystem::status("link-name"))<<endl;
谁知道为什么? (编译过程中没有警告也没有错误) 该链接是使用以下命令创建的:
ln -s file-name link-name
并且 ls 命令说它是一个链接:
ls -l link-name
lrwxrwxrwx 1 myname mygroup 8 juil. 23 14:12 link-name -> file-name
谢谢!
编辑:另一方面,函数 boost::filesystem::is_regular_file 总是返回 true。
最佳答案
您应该使用 symlink_status(const path& p)
,如 boost reference documentation .
file_status symlink_status(const path& p);
Returns: Same as status(), except that if the attributes indicate a symbolic link, as if by ISO/IEC 9945 S_ISLNK(), return file_status(symlink_file).
关于c++ - Boost::filesystem::is_symlink() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24911154/