std::filesy...copy_symlink(3)

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

πŸŽ€ NAME πŸŽ€

std::filesystem::copy_symlink β€” okay so this is the function that copies a symlink to another location πŸ’…. You’re reading the C++ Standard Libary manual page for it, bestie ✨ (yes, that’s the manual name, keep it cute).

✨ Synopsis ✨

Defined in header <filesystem>
void copy_symlink( const std::filesystem::path& from,   (1) (since C++17)
                   const std::filesystem::path& to);
void copy_symlink( const std::filesystem::path& from,
                   const std::filesystem::path& to,      (2) (since C++17)
                   std::error_code& ec ) noexcept;

Copies a symlink to another location. Like, the whole vibe is: point at a symlink, make another symlink in a new spot 🌸.

Here’s the tea on the overloads:

  1. Overload (1) effectively calls f(read_symlink(from), to) where f is create_symlink or create_directory_symlink, depending on whether from resolves to a file or directory. Periodt.
  2. Overload (2) effectively calls f(read_symlink(from, ec), to, ec) where f is create_symlink or create_directory_symlink, depending on whether from resolves to a file or directory. Same energy, but with the ec out-parameter πŸ’«.

🫢 Parameters 🫢

  • from β€” path to a symbolic link to copy. The original symlink bestie.
  • to β€” destination path of the new symlink. Where the copy lands.
  • ec β€” out-parameter for error reporting in the non-throwing overload. Your error-code bestie for overload (2).

πŸ’« Return value πŸ’«

(none) β€” yep, it returns literally nothing. It’s giving β€œdo the thing and dip” πŸ’….

😭 Exceptions 😭

Any overload not marked noexcept may throw std::bad_alloc if memory allocation fails. No cap, memory is a thing 😭.

  1. Throws std::filesystem::filesystem_error on underlying OS API errors, constructed with from as the first path argument, to as the second path argument, and the OS error code as the error code argument. So if the OS says nope, this is the dramatic throw πŸ’€.
  2. Sets a std::error_code& parameter to the OS API error code if an OS API call fails, and executes ec.clear() if no errors occur. Chill overload behavior 🫢.

🌸 Example 🌸

This section is incomplete. Reason: no example. Not me leaving the example section empty πŸ™ˆ β€” the page literally says it’s incomplete, and the reason is no example.

πŸ‘‘ See also πŸ‘‘

  • copy β€” copies files or directories (C++17) (function)
  • copy_file β€” copies file contents (C++17) (function)
  • create_symlink β€” (C++17) (function)
  • create_directory_symlink β€” creates a symbolic link (C++17) (function)
  • read_symlink β€” obtains the target of a symbolic link (C++17) (function)

πŸ“ Category πŸ“

  • Todo no example

made with πŸ’– from source http://cppreference.com, version/date 2024.06.10 β€” page std::filesy...copy_symlink(3) β€” mwah, bestie πŸ’‹βœ¨

πŸ“¦ where this page comes from