名稱空間
變體
操作

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 << "Current root path is: " << fs::current_path().root_path() << '\n';
}

可能的輸出

Current root path is: "C:\"

[編輯] 參閱

返回路徑的根名(如果存在)
(public member function) [編輯]
返回路徑的根目錄(如果存在)
(public member function) [編輯]