File System Iterator for C ++

I need a basic C ++ - STL-like container for the file system.

eg.

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

etc..

Is there something similar?

+4
source share
4 answers

Yes. It exists. Almost similar, at least, which can work with STL iterators and containers.

boost :: filesystem

Example:

 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; } 

I suppose you would now like to look at directory_iterator to find out what else it provides.

+5
source

The other is STLSOFT platformstl :: readdir_sequence.

An example is presented here.

+2
source

I believe the boost :: filesystem library has this functionality.

+1
source

There is something in Visual C ++ 2012. See C ++ 11 File System (VS2012) . Also http://msdn.microsoft.com/en-us/library/hh874694.aspx for implementing VS2013.

0
source

All Articles