std::filesystem::path::root_directory
来自 cppreference.cn
< cpp | filesystem | path
path root_directory() const; |
(C++17 起) | |
返回通用格式路径的根目录。若路径(以通用格式)不含根目录,则返回 path()。
目录 |
[编辑] 参数
(无)
[编辑] 返回值
路径的根目录。
[编辑] 异常
可能抛出实现定义的异常。
[编辑] 示例
运行此代码
#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'; }
可能的输出
The current path "C:\Users\abcdef\Local Settings\temp" decomposes into: root name "C:" root directory "\" relative path "Users\abcdef\Local Settings\temp"
[编辑] 参阅
返回路径的根名(如果存在) (公开成员函数) | |
返回路径的根路径(如果存在) (公开成员函数) |