Most of the <filesystem> header's facilities are concerned with examining the filesystem, not modifying it. But there are several gems hidden in the rubble. Many of these functions seem designed to make the effects of the classic POSIX command-line utilities available in portable C++:
- fs::copy_file(old_path, new_path) : Copy the file at old_path to a new file (that is, a new inode) at new_path, as if by cp -n. Error if new_path already exists.
- fs::copy_file(old_path, new_path, fs::copy_options::overwrite_existing): Copy old_path to new_path. Overwrite new_path if possible. Error if new_path exists and is not a regular file, or if it's the same as old_path.
- fs::copy_file(old_path, new_path, fs::copy_options::update_existing): Copy old_path to new_path. Overwrite new_path if and only if it's older than the file at old_path.
- fs::copy...