- filesystem[meta header]
- std::filesystem[meta namespace]
- path[meta class]
- function[meta id-type]
- cpp17[meta cpp]
path root_path() const;
パスが保持しているルートパスを取得する。
ルートパスは、ルート名とディレクトリ区切り文字を合わせた文字列である。
return root_name() / root_directory();
- root_name()[link root_name.md]
- root_directory()[link root_directory.md]
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::path p = "/usr/bin/clang";
fs::path root_p = p.root_path();
std::cout << root_p << std::endl;
}
- root_path()[color ff0000]
"/"
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::path p = "C:/Program Files/a.txt";
fs::path root_p = p.root_path();
std::cout << root_p << std::endl;
}
- root_path()[color ff0000]
"C:/"
- C++17
- Clang:
- GCC: 8.1
- Visual C++: 2017 Update 7