名稱空間
變體
操作

std::filesystem::path::root_name

來自 cppreference.com
< cpp‎ | filesystem‎ | path
 
 
 
 
path root_name() const;
(C++17 起)

返回泛型格式路徑的根名。若路徑(以泛型格式)不包含根名,則返回 path()

目錄

[編輯] 引數

(無)

[編輯] 返回值

路徑的根名。

[編輯] 異常

可能丟擲實現定義的異常。

[編輯] 示例

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
 
int main()
{
    std::cout << "Current root name is: " << fs::current_path().root_name() << '\n';
}

可能的輸出

Current root name is: "C:"

[編輯] 參閱

返回路徑的根目錄(如果存在)
(公開成員函式) [編輯]
返回路徑的根路徑(如果存在)
(公開成員函式) [編輯]