std::filesy...::root_name(3)

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

🌸 NAME 🌸

okay so this page is literally std::filesystem::path::root_name - std::filesystem::path::root_name (yes, she said it twice, and she ate πŸ’…). We’re chilling in the C++ Standard Libary manual under the std::filesy...::root_name(3) banner, and this whole page is about the std::filesystem::path::root_name member function. no cap. πŸŽ€


✨ Synopsis ✨

path root_name() const;  (since C++17)

This one returns the root name of the generic-format path. If the path (in generic format) does not include root name, it returns path(). that’s the vibe check, bestie. πŸ¦‹


🫢 Parameters 🫢

  • (none) β€” literally no parameters. zero. nada. she takes nothing and still serves. ✨

πŸ’– Return value πŸ’–

The root name of the path. periodt. πŸ“


😭 Exceptions 😭

May throw implementation-defined exceptions. so like, the implementation gets to pick the drama, and you just gotta deal. πŸ’€


πŸ”₯ Example πŸ”₯

Run this code, bestie:

// Run this code

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

int main()
{
    std::cout << "Current root name is: " <<
       fs::current_path().root_name() << '\n';
}

Possible output:

Current root name is: "C:"

πŸ‘‘ See also πŸ‘‘

  • root_directory β€” returns the root directory of the path, if present (public member function). 🌈
  • root_path β€” returns the root path of the path, if present (public member function). πŸ‘‘

mwah πŸ’‹ this cutie was served from http://cppreference.com, dated 2024.06.10, under the std::filesy...::root_name(3) banner. go off, bestie. πŸŒΈπŸ’œπŸ‘‘

πŸ“¦ where this page comes from