2016-01-31 22:19:23 +00:00
|
|
|
#include <ostd/io.hh>
|
|
|
|
#include <ostd/filesystem.hh>
|
2016-07-31 19:40:25 +00:00
|
|
|
#include <ostd/range.hh>
|
2016-01-31 22:19:23 +00:00
|
|
|
|
|
|
|
using namespace ostd;
|
|
|
|
|
2017-02-16 17:48:14 +00:00
|
|
|
void list_dirs(string_range path, int off = 0) {
|
2017-02-16 19:39:05 +00:00
|
|
|
directory_stream ds{path};
|
2016-01-31 22:19:23 +00:00
|
|
|
/* iterate all items in directory */
|
2017-01-23 23:35:07 +00:00
|
|
|
for (auto v: iter(ds)) {
|
2017-02-16 19:39:05 +00:00
|
|
|
if (v.type() != file_type::DIRECTORY) {
|
2016-01-31 22:19:23 +00:00
|
|
|
continue;
|
2016-07-31 19:40:25 +00:00
|
|
|
}
|
|
|
|
for_each(range(off), [](int) { write(' '); });
|
2016-01-31 22:19:23 +00:00
|
|
|
writeln(v.filename());
|
|
|
|
list_dirs(v.path(), off + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2016-07-31 19:40:25 +00:00
|
|
|
if (argc < 1) {
|
|
|
|
return 1;
|
|
|
|
}
|
2016-01-31 22:19:23 +00:00
|
|
|
list_dirs(argv[1]);
|
|
|
|
return 0;
|
2016-02-07 21:17:15 +00:00
|
|
|
}
|