名前空間
変種
操作

std::filesystem::path::root_directory

提供: cppreference.com
< cpp‎ | filesystem‎ | path
 
 
 
 
path root_directory() const;
(C++17以上)

汎用形式のパスのルートディレクトリを返します。 汎用形式のパスにルートディレクトリが含まれていなければ path() を返します。

目次

[編集] 引数

(なし)

[編集] 戻り値

パスのルートディレクトリ。

[編集] 例外

(なし)

[編集]

#include <iostream>
#include <filesystem>
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"

[編集] 関連項目

もしあれば、パスのルート名を返します
(パブリックメンバ関数) [edit]
もしあれば、パスのルートパスを返します
(パブリックメンバ関数) [edit]