Given an instance of std::filesytem::path
in a Linux environment, what exactly do the root_name
, root_directory
, and root_path
methods return?
I understand that in the Linux/POSIX environment, the UNC notation is not used. Therefore, is it true that in the Linux/POSIX environment, root_name
has no function or meaning?
While cppreference does take a bit of reading to find out what the string would actually be, you can always do a bit of testing yourself:
#include <filesystem>
#include <iostream>
int main()
{
std::filesystem::path path="/tmp/foo/bar";
std::cout << "full: " << path << '\n';
std::cout << "root name: " << path.root_name() << '\n';
std::cout << "root path: " << path.root_path() << '\n';
std::cout << "root directory: " << path.root_directory() << '\n';
}
stieber@gatekeeper:~ $ g++ Test.cpp && ./a.out
full: "/tmp/foo/bar"
root name: ""
root path: "/"
root directory: "/"