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?
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?
- 4 Did you perform any attempt to write a simple program or copy one from cppreference with outputs of results of mentioned functions? – 3CxEZiVlQ Commented Mar 16 at 18:33
- 1 Currently I don't have access to an up-to-date Linux box. Just writing some code and wanted to make it portable as possible. If I have violated some protocol, I apolofize. I'm not a frequent user here. – crsguy Commented Mar 16 at 20:53
- Yes, the SO rules were violated, not enough efforts for finding an answer were demonstrated. You don't need access to a linux box. You can use online compiler explorers. Moreover, if you RTM you would realize the "Run this code" button. – 3CxEZiVlQ Commented Mar 16 at 21:29
- Docker is an option to give yourself updated tooling as well. Or a VM. – sweenish Commented Mar 17 at 11:56
- Thanks for your patience. I didn't realize you could actually put your own code in the "RTM' window. As an old old fart, I find this new stuff to be quite unimaginable. – crsguy Commented Mar 20 at 16:02
1 Answer
Reset to default 3While 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: "/"