DirectoryIterator/File should support modern C++ for-loops

Rather than old-style C++:

{
    DirectoryIterator iter (file, ...);
    while (iter.next())
        something (iter.getFile());
}

It would be much nicer and more consistent to have:

for (auto c : file.iterateChildFiles (...))
    something (c);

Vote if you agree! As for myself I’ve already used up my votes for more important things…

1 Like

Can you just use std::filesystem?

    for(auto& p: std::filesystem::recursive_directory_iterator("my_dir"))
        std::cout << p.path() << '\n';
1 Like

Thanks, just tried, and apparently I can’t

JUCE6 will include a new RangedDirectoryIterator which has ranged-for support, and which replaces the current DirectoryIterator.

3 Likes