std::experi...ot_directory(3)

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

πŸŽ€ std::experimental::filesystem::path::root_directory πŸŽ€

okay so bestie, this page is from the C++ Standard Libary manual β€” the page id is std::experi...ot_directory(3) β€” and it’s all about the member function std::experimental::filesystem::path::root_directory. no cap, it’s a tiny one, but every detail is staying. πŸ’…

πŸ’– NAME πŸ’–

std::experimental::filesystem::path::root_directory β€” literally the same name, twice, because that’s how this page rolls. 🫢

✨ Synopsis ✨

Here’s the signature, copied exactly because we do not mess with code:

path root_directory() const;  (filesystem TS)

It returns the root directory of the path. If the path does not include root name, returns path(). (That’s the original wording, bestie β€” keep it close.) 🌸

🌈 Parameters 🌈

  • (none) β€” yep, zero parameters. the void is the vibe. πŸ’€

πŸ¦‹ Return value πŸ¦‹

The root directory of the path. that’s it. that’s the return value. ✨

πŸ”₯ Exceptions πŸ”₯

May throw implementation-defined exceptions. so like, it may throw, and the details are implementation-defined β€” no invented drama from me. 😭

πŸ“ Example πŸ“

The original says β€œRun this code,” so here’s the code, exactly:

// Run this code

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

int main()
{
    fs::path p = fs::current_path();

    std::cout << "The current path " << p << " decomposes into:\n"
              << "root name " << p.root_name() << '\n'
              << "root directory " << p.root_directory() << '\n'
              << "relative path " << p.relative_path() << '\n';
}

Possible output:

The current path "C:\Users\abcdef\Local Settings\temp" decomposes into:
root name "C:"
root directory "\"
relative path "Users\abcdef\Local Settings\temp"

πŸ‘‘ See also πŸ‘‘

  • root_name β€” returns the root-name of the path, if present. it’s a public member function. πŸ’œ
  • root_path β€” returns the root path of the path, if present. also a public member function. ⭐

🏷️ Category 🏷️

  • Noindexed pages β€” that’s the category listed on the page. periodt.

🫢 okay that’s the whole page, bestie β€” source/version/date: cppreference.com Β· 2024.06.10 Β· manual: std::experi...ot_directory(3) (C++ Standard Libary) πŸ’–

πŸ“¦ where this page comes from