Iterate Through Files In a Folder/Directory?

Hello --

I know how to read and write to files; however, might there be a way to iterate through the list of files in a folder so that I can pass each one as a variable? If possible, may you list a solution that is not UNIX-specific? (I will cross-post this on the Windows forum).

Thanks!
The C++ in itself does not have (had) such functionality. Each OS has a different API that you have to use.

One would define an interface and write implementation for each OS. Then, conditionally compile only the current platform's implementation. The rest of the program uses the interface, blissfully unaware of how things are really done.


That is the theory. In practice, reinventing wheel is not fun. Therefore, use a third-party library that has already
defined interface and supplies implementations for multiple platforms.
Examples:
the Qt framework http://www.qt.io/
the boost::filesystem http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm


Edit: and apparently the C++17 (as shown in the other thread of yours).
Last edited on
Topic archived. No new replies allowed.