std::experimental::filesystem::path::root_directory
來自 cppreference.com
< cpp | experimental | fs | path
path root_directory() const; |
(filesystem TS) | |
返回路徑的根目錄。如果路徑不包含根名稱,則返回 path()。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
路徑的根目錄。
[編輯] 異常
可能丟擲實現定義的異常。
[編輯] 示例
執行此程式碼
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::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"
[編輯] 參閱
返回路徑的根名(如果存在) (public member function) | |
返回路徑的根路徑(如果存在) (public member function) |