How it works...

The filesystem library is located in the <filesystem> header under the std::filesystem namespace. These two tests, although pretty simple, were needed to show how powerful the filesystem library is. The output of the first program is as follows:

A complete list of std::filesystem methods can be found here: https://en.cppreference.com/w/cpp/header/filesystem.

std::filesystem::create_directories create a directory (recursively, if test/src does not exist) in the current folder, in this case. Of course, an absolute path is managed too and the current line would be perfectly valid, that is, std::filesystem::create_directories("/usr/local/test/config"); ...

Get C++ System Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.