清单目录中的boost ::文件系统的文件递归

编程入门 行业动态 更新时间:2024-10-14 18:16:38
本文介绍了清单目录中的boost ::文件系统的文件递归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用新的动力,V1.5.3,开展这项工作就像下,由于类recursive_directory_iterator(我没有写递归code):

I'm using new boost, v1.5.3, to carry out this task like following, thanks to the class recursive_directory_iterator (I don't have to write recursive code):

void ListDirRec(const char *Dir, vector<string>& DirFileList, const char* ext) { recursive_directory_iterator rdi(Dir); recursive_directory_iterator end_rdi; DirFileList.empty(); string ext_str0(ext); for (; rdi != end_rdi; rdi++) { rdi++; //cout << (*di).path().string() << endl; cout << (*rdi).path().string() << endl; //cout << " <----- " << (*rdi).path().extension() << endl; //string ext_str1 = (*rdi).path().extension().string(); if (ext_str0pare((*rdi).path().extension().string()) == 0) { DirFileList.push_back((*rdi).path().string()); } }

函数列表文件与特定扩展。此功能为案件,但经常返回断言失败错误,如:

the function list files with specific extension. This function works for cases but frequently return an "assertion fails error" like:

**** Internal program error - .... assertion (m_imp.get()) ... operations.hpp(952): dereference of end recursive_directory_iterator

我刚刚想出这个错误的原因。可以在任何尝试..赶上帮助?在此先感谢您的帮助。

I barely figure out the cause of this error. Can any try.. catch help? thanks in advance for any help

推荐答案

正在递增 RDI 内循环,以及在为声明:

You are incrementing rdi inside the loop as well as in the for declaration:

for (; rdi != end_rdi; rdi++) { rdi++;

这意味着 RDI 可能是 end_rdi (结束迭代器,这意味着过去的最后一个元素)内你的循环。有你这样做的原因是什么? (如果这是故意的,你应该检查,以确保 RDI!= end_rdi 您增加后再次它。)

That means that rdi might be end_rdi (the end-iterator, which means past the last element) within your loop. Is there any reason you're doing this? (If this is intentional, you should check to make sure rdi != end_rdi again after you increment it.)

更多推荐

清单目录中的boost ::文件系统的文件递归

本文发布于:2023-05-28 06:58:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/315158.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   文件系统   清单   文件   目录中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!