In this section, we will implement a little tool that lists all files in any user provided directory. It will not only list the filenames, but also their type, size, and access permissions.
- First, we need to include some headers and declare that we use the namespaces std and filesystem by default.
#include <iostream> #include <sstream> #include <iomanip> #include <numeric> #include <algorithm> #include <vector> #include <filesystem> using namespace std; using namespace filesystem;
- One helper function that we are going to need is file_info. It accepts a directory_entry object reference and extracts the path from it, as well as a file_status object (using the status function), which contains file type and permission information. ...