std::filesystem::path::root_path
来自cppreference.com
< cpp | filesystem | path
path root_path()const; | (C++17 起) | |
返回路径的根路径。若路径不包含根路径,则返回 path()。
相当于返回 root_name()/ root_directory()。
目录 |
[编辑]参数
(无)
[编辑]返回值
路径的根路径。
[编辑]异常
可能会抛出由实现定义的异常。
[编辑]示例
运行此代码
#include <filesystem>#include <iostream>namespace fs = std::filesystem; int main(){std::cout<<"当前根路径为: "<< fs::current_path().root_path()<<'\n';}
可能的输出:
当前根路径为: "C:\"
[编辑]参阅
若存在则返回路径的根名 (公开成员函数) | |
若存在则返回路径的根目录 (公开成员函数) |