std::experi...copy_options(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::experimental::filesystem::copy_options β€” std::experimental::filesystem::copy_options.

Okay bestie, this is the std::experi...copy_options(3) page from the C++ Standard Libary manual β€” yes, that spelling is literally what's up there, we keep it πŸ’….


✨ Synopsis ✨

Defined in header <experimental/filesystem>:

enum class copy_options {

    none = 0,
    skip_existing = 1,
    overwrite_existing = 2,
    update_existing = 4,
    recursive = 8,                           (filesystem TS)
    copy_symlinks = 16,
    skip_symlinks = 32,
    directories_only = 64,
    create_symlinks = 128,
    create_hard_links = 256

};

This type is literally the menu of available options that control the behavior of the copy() and copy_file() function.

copy_options satisfies the requirements of BitmaskType (which means the bitwise operators operator&, operator|, operator^, operator~, operator&=, operator|=, and operator^= are defined for this type).


πŸ’… Member constants πŸ’…

⚠️ Important, bestie: at most one copy option in each of the following options groups may be present, otherwise the behavior of the copy functions is undefined. So don't stack options within a group unless you enjoy chaos πŸ’€.

options controlling copy_file() when the file already exists

  • none β€” 0 β€” Report an error (default behavior).
  • skip_existing β€” 1 β€” Keep the existing file, without reporting an error.
  • overwrite_existing β€” 2 β€” Replace the existing file.
  • update_existing β€” 4 β€” Replace the existing file only if it is older than the file being copied.

options controlling the effects of copy() on subdirectories

  • none β€” 0 β€” Skip subdirectories (default behavior).
  • recursive β€” 8 β€” Recursively copy subdirectories and their content.
  • none β€” 0 β€” Follow symlinks (default behavior).
  • copy_symlinks β€” 16 β€” Copy symlinks as symlinks, not as the files they point to.
  • skip_symlinks β€” 32 β€” Ignore symlinks.

options controlling the kind of copying copy() does

  • none β€” 0 β€” Copy file content (default behavior).
  • directories_only β€” 64 β€” Copy the directory structure, but do not copy any non-directory files.
  • create_symlinks β€” 128 β€” Instead of creating copies of files, create symlinks pointing to the originals. Note: the source path must be an absolute path unless the destination path is in the current directory.
  • create_hard_links β€” 256 β€” Instead of creating copies of files, create hardlinks that resolve to the same files as the originals.

🌸 Example 🌸

The page says // Run this code and then gives you this little sandbox demo:

#include <experimental/filesystem>
#include <fstream>
#include <iostream>
namespace fs = std::experimental::filesystem;

int main()
{
    fs::create_directories("sandbox/dir/subdir");
    std::ofstream("sandbox/file1.txt").put('a');
    fs::copy("sandbox/file1.txt", "sandbox/file2.txt"); // copy file
    fs::copy("sandbox/dir", "sandbox/dir2"); // copy directory (non-recursive)
    // sandbox holds 2 files and 2 directories, one of which has a subdirectory
    // sandbox/file1.txt
    // sandbox/file2.txt
    // sandbox/dir2
    // sandbox/dir
    //    sandbox/dir/subdir
    fs::copy("sandbox", "sandbox/copy", fs::copy_options::recursive);
    // sandbox/copy holds copies of the above files and subdirectories
    fs::remove_all("sandbox");
}

πŸ”₯ See also πŸ”₯

  • copy β€” copies files or directories (function)
  • copy_file β€” copies file contents (function)

πŸŽ€ Category πŸŽ€

  • Noindexed pages

Source: http://cppreference.com β€” page std::experi...copy_options(3) β€” date/version stamp 2024.06.10. Bye bestie, go make some iconic copies πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from