std::filesystem::path:: relative_path
From cppreference.net
<
cpp
|
filesystem
|
path
C++
std::filesystem::path
| Member types | ||||||||||||||||||||||||||
| Member constants | ||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Path decomposition | ||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||
|
path relative_path
(
)
const
;
|
(C++17부터) | |
root-path 에 상대적인 경로를 반환합니다. 즉, * this 의 모든 일반 형식 구성 요소로 구성된 경로명 중 root-path 이후 부분입니다. * this 가 빈 경로인 경우 빈 경로를 반환합니다.
목차 |
매개변수
(없음)
반환값
root 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-path " << p.root_path() << '\n' << "relative path " << p.relative_path() << '\n'; }
가능한 출력:
The current path "C:\Users\abcdef\Local Settings\temp" decomposes into: root-path "C:\" relative path "Users\abcdef\Local Settings\temp"
참고 항목
|
경로에 루트 이름이 존재하는 경우 반환합니다
(public member function) |
|
|
경로에 루트 디렉터리가 존재하는 경우 반환합니다
(public member function) |
|
|
경로에 루트 경로가 존재하는 경우 반환합니다
(public member function) |