[英]How C++ boost::filesystem detect if path is file or directory?
In boost::filesystem library is there any way to determine if the path is directory or file? 在boost :: filesystem库中,有什么方法可以确定路径是目录还是文件?
My scenario is : I have some folders and files which i need full path of the all files and push it to vector, so i did this : 我的情况是:我有一些文件夹和文件,我需要所有文件的完整路径并将其推送到vector,所以我这样做了:
for ( boost::filesystem::recursive_directory_iterator end, dir(pathBase);
dir != end; ++dir ) {
if ( boost::filesystem::exists( dir->path() ) )
{
std::cout << dir->path() << "\n"; // full path
filenames.push_back(dir->path().string());
}
}
The problem is the exists
method check if directory or file exist and could not detect their type(file or directory). 问题是exists
方法检查目录或文件是否存在并且无法检测到它们的类型(文件或目录)。
So how can i get only files with boost library? 那么我怎样才能只获得带有Boost库的文件?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.