Creating, copying, and deleting files and directories
Operations with files, such as copying, moving, and deleting, or with directories, such as creating, renaming, and deleting, are all supported by the filesystem
library. Files and directories are identified using a path (which can be absolute, canonical, or relative), a topic that was covered in the previous recipes. In this recipe, we will look at what the standard functions for the previously mentioned operations are and how they work.
Getting ready
Before going forward, you should read the Working with filesystem paths recipe. The introductory notes from that recipe also apply here. However, all of the examples in this recipe are platform-independent.
For all of the following examples, we will use the following variables, and assume the current path is C:\Users\Marius\Documents
on Windows and /home/marius/docs
for a POSIX system:
auto err = std::error_code{};
auto basepath = fs::current_path();
auto path = basepath...