#include <boost::filesystem.hpp>
using namespace boost::filesystem;
void file_executor::iterate_folder(const string full_path)
{directory_iterator end;
for(directory_iterator pos(full_path);pos !=end; ++pos){
boost::filesystem::path path_(*pos);
if(is_regular(path_)){
string s= path_.string();
vector_files.push_back(s);
files_num ++;
}
else if(is_directory(path_)){
iterate_folder(path_.string());
}
}
}
本文介绍了一个使用Boost库遍历指定路径下所有文件及子文件夹的方法。通过递归方式,该方法能够收集所有普通文件的路径,并统计文件数量。适用于需要批量处理文件的应用场景。
1254

被折叠的 条评论
为什么被折叠?



