boost::files系统:带筛选器的递归目录迭代器
boost::filesystem::recursive_directory_iterator with filter
我需要递归地从目录及其子目录中获取所有文件,但不包括几个目录。我知道他们的名字。是否可以使用boost::filesystem::recursive_directory_editor?
是的,在遍历目录时,您可以测试排除列表上的名称,并使用递归迭代器的no_push()
成员来防止它进入这样的目录,比如:
void selective_search( const path &search_here, const std::string &exclude_this_directory)
{
using namespace boost::filesystem;
recursive_directory_iterator dir( search_here), end;
while (dir != end)
{
// make sure we don't recurse into certain directories
// note: maybe check for is_directory() here as well...
if (dir->path().filename() == exclude_this_directory)
{
dir.no_push(); // don't recurse into this directory.
}
// do other stuff here.
++dir;
}
}
相关文章:
- 使用std::multimap迭代器创建std::list
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- C++中带有List类的迭代器Segfault
- 如何在c++迭代器类型中包装std::chrono
- 如何使用迭代器在 c++ 中的递归函数中传递值?
- 树不维护递归迭代器成员
- 使用迭代器对向量的C 递归初始化产生不一致的结果
- 为什么后缀失败并且前缀在传递迭代器作为参数并在尾部位置递归时工作正常
- 递归 - >迭代
- 迭代器回到递归方法的开头
- 使用迭代器的递归调用崩溃
- OpenMesh递归迭代
- 在递归函数中使用迭代器会导致分段错误
- 递归函数中迭代器的 Seg 错误
- 递增迭代器并在递归循环中传递参数
- boost::files系统:带筛选器的递归目录迭代器
- C++:如何递归/迭代搜索HTML文件(使用Boost C++)
- 如何在递归函数中使用迭代器
- Qt c++ QDomDocument,递归迭代XML数据,检索没有子数据的文本元素
- c++设置迭代器后的下一个分隔符递归