|
Boost Users : |
Subject: Re: [Boost-users] Fwd: Boost::Filesystem - How to iterate, through the whole drive
From: degski (degski_at_[hidden])
Date: 2018-11-18 08:04:55
On Sun, 18 Nov 2018 at 05:31, Richard Závodný via Boost-users <
boost-users_at_[hidden]> wrote:
>
>
> ---------- Forwarded message ---------
> From: Richard Závodný <zavodnyrichard_at_[hidden]>
> Date: Sat, Nov 17, 2018, 3:59 PM
> Subject: Boost::Filesystem - How to iterate, through the whole drive
> To: <boost-users_at_[hidden]>
>
>
> Hey guys, I need iterate over all directories from starting path. If I
> start iterating from C:\some-dir it works very well, however if I try to
> iterate from C:\, it doesn't work. How can iterate through the whole drive?
> Thank you.
>
>
> Code is here: https://pastebin.com/mpsKJxH2
> <https://pastebin.com/3J6FEMG5>. The problem I experience is commented
> right in the code section (line 1, 13 and 25).
>
This works for me, either with boost-1.68 (not that I think that matters)
or the STL-VC-15.9.1 (/std:c++17):
#include <iostream>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
int main ( ) {
for ( auto & p : fs::recursive_directory_iterator ( "d:\\" ) ) {
std::cout << p.path ( ) << '\n';
}
}
Note that: "The iteration order is unspecified, except that each directory
entry is visited only once."
degski
-- *âIf something cannot go on forever, it will stop" - Herbert Stein*
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net