在c++ boost库中使用directory_iterator列出和获取文件名的问题
problems in listing and getting file names using directory_iterator with C++ boost library
我试图使用boost库中的目录迭代器,我想做一个循环,我迭代一个目录并将文件名放在一个变量中,我可以使用leaf()函数之前,但现在它已弃用。我不能使用path().filename(),甚至可以使用native()和string(),因为C编译器会给我错误。我如何修复下面的代码?
boost::filesystem::directory_iterator end_iter;
for (boost::filesystem::directory_iterator file(dir);file != end_iter;++file)
{
/*check if file is image */
string fileName=file->path().filename().native(); //the error happens here
// i can use path().filename().string() either
boost::match_results<string::const_iterator> what;
if (0 == boost::regex_search(fileName, what, e, boost::match_default))
{
continue;
};
...
谢谢。
根据@Casey和@rectummelancolique的建议,在makefile中-lboost_filesystem之后添加-lboostrongystem,问题就解决了。
相关文章:
- 从 Makefile 中的 $@ 获取文件名
- 有没有一种简单的方法可以从 c++ 中的路径获取文件名?
- 从 SetClipboardData 挂钩获取文件名
- 是否有一种便携式/标准的方法可以在堆栈跟踪中获取文件名和亚麻布
- 如何从文件夹中获取文件名,并将它们添加到QT中的孩子中
- 从 Windows 上的 tmpfile() 获取文件名
- 是否可以从FSEvent id获取文件名
- 如何在单击mfc代码中的关系文件时获取文件名
- 如何在Qt中获取文件名
- 是否有一个WinAPI可以从带有可选空格和其他参数的命令行获取文件名
- 从控制台应用中的命令行参数获取文件名C++
- 从流中获取文件名(或路径)
- 如何在下载文件之前获取文件名
- 在调用函数的任何位置获取文件名和函数名
- 在c++ boost库中使用directory_iterator列出和获取文件名的问题
- 从路径中获取文件名
- gtkmm 和 FileChooserButton 无法获取文件名
- 如何从http请求体字符串获取文件名
- 如何在GNU Makefile中只获取文件名而不扩展名
- 如何从argv中获取文件名并将其与ifstream一起使用/将其更改为ofstream的txt