How to list files and folders recursively and separately with Boost and C++

Aminos

In the boost documentation I found the code to list a directory files AND folders (but not recursively :( ), but I don't know how to do to generate only the list of all files, even those that are in the sub directories (recursively) OR the list of all folders (recursively too).

sehe

To get you started:

#include <boost/filesystem.hpp>
#include <boost/range/iterator_range.hpp>

namespace fs = boost::filesystem; 

#include <iostream>

int main() {

    for (auto& entry : boost::make_iterator_range(fs::recursive_directory_iterator("."), {}))
    {
        if (fs::is_regular_file(entry))
            std::cout << entry.path() << "\n";
    }

}

Prints e.g.

"./odata/marshal/json_light_test.cpp"
"./odata/marshal/core_test.cpp"
"./odata/marshal/json_verbose_test.cpp"
"./odata/edm/example_test.cpp"
"./odata/edm/builtin_test.cpp"
"./misc/naive_ptr_tests.cpp"
"./json/generic_visitor_tests.cpp"
"./json/json_tests.cpp"
"./azure/storage/test_service_definitions.hpp"
"./azure/storage/blob_tests.cpp"
"./azure/storage/table_tests.cpp"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can we list all files and folders recursively?

From Dev

How do I compare two folders recursively and generate a list of files and folders that are different?

From Dev

Recursively listing of files and folders in C#

From Dev

How to rename folders and files recursively in MacOS

From Dev

Recursively set all files and folders to 777 from this list

From Dev

Printing all files and folders in a path in Linux, recursively, in C

From Dev

How to recursively remove execute permissions from files without touching folders?

From Dev

How to recursively copy only the files from folders and subfolders?

From Dev

Delete files and folders recursively in subdirectories

From Dev

How to load list of Azure blob files recursively?

From Dev

How to recursively remove all but list of files?

From Dev

How to recursively list all hidden files and directories?

From Dev

List folders, sub folders and files in a given path in C (windows)

From Dev

How to list all the folders and its files in php

From Dev

How to search and list files and folders with specific pattern?

From Dev

How to show list all folders not files in path

From Dev

How to embed files separately?

From Dev

List files on FTPServer recursively

From Dev

List pdf files recursively

From Dev

List files recursively on OSX?

From Dev

How to recursively move batches of 20 files into numbered folders from folder of 1000 files

From Dev

How to recursively list files (and only files) in windows command propmpt?

From Dev

Get files & folders recursively in Windows Store Applications

From Dev

Find and Rename recursively in folders, subfolders and multiple files

From Dev

zip all files and folders recursively in bash

From Dev

7zip recursively archive files in folders

From Dev

Recursively search folders with pattern and get files within it

From Dev

Find recursively in folders, subfolders and multiple files

From Dev

List folders and subfolder but not files

Related Related

  1. 1

    How can we list all files and folders recursively?

  2. 2

    How do I compare two folders recursively and generate a list of files and folders that are different?

  3. 3

    Recursively listing of files and folders in C#

  4. 4

    How to rename folders and files recursively in MacOS

  5. 5

    Recursively set all files and folders to 777 from this list

  6. 6

    Printing all files and folders in a path in Linux, recursively, in C

  7. 7

    How to recursively remove execute permissions from files without touching folders?

  8. 8

    How to recursively copy only the files from folders and subfolders?

  9. 9

    Delete files and folders recursively in subdirectories

  10. 10

    How to load list of Azure blob files recursively?

  11. 11

    How to recursively remove all but list of files?

  12. 12

    How to recursively list all hidden files and directories?

  13. 13

    List folders, sub folders and files in a given path in C (windows)

  14. 14

    How to list all the folders and its files in php

  15. 15

    How to search and list files and folders with specific pattern?

  16. 16

    How to show list all folders not files in path

  17. 17

    How to embed files separately?

  18. 18

    List files on FTPServer recursively

  19. 19

    List pdf files recursively

  20. 20

    List files recursively on OSX?

  21. 21

    How to recursively move batches of 20 files into numbered folders from folder of 1000 files

  22. 22

    How to recursively list files (and only files) in windows command propmpt?

  23. 23

    Get files & folders recursively in Windows Store Applications

  24. 24

    Find and Rename recursively in folders, subfolders and multiple files

  25. 25

    zip all files and folders recursively in bash

  26. 26

    7zip recursively archive files in folders

  27. 27

    Recursively search folders with pattern and get files within it

  28. 28

    Find recursively in folders, subfolders and multiple files

  29. 29

    List folders and subfolder but not files

HotTag

Archive