Namespaces
Variants

std::filesystem::path:: root_directory

From cppreference.net
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"

참고 항목

경로에 루트 이름이 존재하는 경우 이를 반환합니다
(public member function)
경로에 루트 경로가 존재하는 경우 이를 반환합니다
(public member function)