std::filesystem::path::root_directory
來自 cppreference.com
< 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"
[編輯] 參閱
返回路徑的根名(如果存在) (公開成員函式) | |
返回路徑的根路徑(如果存在) (公開成員函式) |