std::filesystem::path::root_path
来自 cppreference.cn
< 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 << "Current root path is: " << fs::current_path().root_path() << '\n'; }
可能的输出
Current root path is: "C:\"
[编辑] 参阅
返回路径的根名(如果存在) (public member function) | |
返回路径的根目录(如果存在) (public member function) |