std::filesy...ot_directory(3)
okay so bestie, welcome to the std::filesy...ot_directory(3) page from the C++ Standard Libary (yes, that spelling is in the building π). Weβre talking about std::filesystem::path::root_directory, and itβs lowkey a tiny member function with main-character energy. Letβs go. π
πΈ NAME πΈ
std::filesystem::path::root_directory β and the description is literally std::filesystem::path::root_directory again. No cap, thatβs the whole NAME section: the function and itself. π
β¨ Synopsis β¨
path root_directory() const; (since C++17)
Returns the root directory of the generic-format path. If the path (in generic format) does not include root directory, it returns path(). That detail is doing a lot of work, so donβt skip it, bestie. π«Ά
π Parameters π
(none)β literally no parameters. Not a one. Itβs giving βI need nothing from youβ energy. β¨
π Return value π
The root directory of the path. Thatβs it. Thatβs the return value. Iconic, honestly. π
π¦ Exceptions π¦
May throw implementation-defined exceptions. So yeah, the implementation gets to decide the drama hereβhandle it accordingly. π
π Example π
// Run this code
#include <filesystem>
#include <iostream>
namespace fs = std::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 (public member function) πroot_pathβ returns the root path of the path, if present (public member function) π
kiss kiss, bestie: this pageβs source is http://cppreference.com, its version/date is 2024.06.10, and the manual page is std::filesy...ot_directory(3). slay. π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms