gpt4 book ai didi

c++ - C++ 的文件系统迭代器

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:25:24 27 4
gpt4 key购买 nike

我想要一个基本的 C++ 类似 STL 的文件系统容器。

例如

std::filesystem::const_iterator i = filesys.begin();  
i->file_name(); i->full_path(),

等..

有这样的东西吗?

最佳答案

是的。它存在。几乎相似,至少可以与 STL 迭代器和容器一起使用。

boost::filesystem

例子:

path p ("directorypath");
std::vector<path> v;
std::copy(directory_iterator(p), directory_iterator(), std::back_inserter(v));
for (std::vector<path>::const_iterator it=v.begin(); it != v.end(); ++it)
{
std::cout << " " << *it << std::endl;
}

我想,现在您想查看 directory_iterator 以发现它还提供了什么。

关于c++ - C++ 的文件系统迭代器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5691336/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com