std::filesystem::path:: parent_path
| Member types | ||||||||||||||||||||||||||
| Member constants | ||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Path decomposition | ||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||
|
path parent_path
(
)
const
;
|
(C++17부터) | |
상위 디렉터리의 경로를 반환합니다.
만약 has_relative_path ( ) 가 false를 반환하면, 결과는 * this 의 사본입니다. 그렇지 않으면, 결과는 일반 형식 경로명이 * this 의 일반 형식 경로명 중 순회 시 하나 적은 요소를 생성하는 가장 긴 접두사인 경로입니다.
목차 |
매개변수
(없음)
반환값
상위 디렉토리로의 경로, 또는 * this 가 has_relative_path ( ) 를 가지지 않을 경우 이 객체의 복사본.
예외
구현 정의 예외를 던질 수 있습니다.
예제
#include <filesystem> #include <iostream> namespace fs = std::filesystem; int main() { for (fs::path p : {"/var/tmp/example.txt", "/", "/var/tmp/."}) std::cout << "The parent path of " << p << " is " << p.parent_path() << '\n'; }
가능한 출력:
The parent path of "/var/tmp/example.txt" is "/var/tmp" The parent path of "/" is "/" The parent path of "/var/tmp/." is "/var/tmp"
참고 항목
|
경로에 루트 이름이 있으면 반환합니다
(public member function) |
|
|
경로에 루트 디렉터리가 있으면 반환합니다
(public member function) |
|
|
경로에 루트 경로가 있으면 반환합니다
(public member function) |