std::filesystem::path:: root_path
From cppreference.net
<
cpp
|
filesystem
|
path
C++
std::filesystem::path
| Member types | ||||||||||||||||||||||||||
| Member constants | ||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Path decomposition | ||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||
|
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:\"
参见
|
返回路径的根名称(如果存在)
(公共成员函数) |
|
|
返回路径的根目录(如果存在)
(公共成员函数) |