O'Reilly logo

C++17 STL Cookbook by Jacek Galowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

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.

  1. 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;
  1. 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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required