std::filesystem:: relative, std::filesystem:: proximate
|
헤더 파일에 정의됨
<filesystem>
|
||
|
path relative
(
const
std::
filesystem
::
path
&
p,
std:: error_code & ec ) ; |
(1) | (C++17부터) |
|
path relative
(
const
std::
filesystem
::
path
&
p,
const std:: filesystem :: path & base = std:: filesystem :: current_path ( ) ) ; |
(2) | (C++17부터) |
|
path relative
(
const
std::
filesystem
::
path
&
p,
const
std::
filesystem
::
path
&
base,
|
(3) | (C++17부터) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
std:: error_code & ec ) ; |
(4) | (C++17부터) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
const std:: filesystem :: path & base = std:: filesystem :: current_path ( ) ) ; |
(5) | (C++17부터) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
const
std::
filesystem
::
path
&
base,
|
(6) | (C++17부터) |
목차 |
매개변수
| p | - | 기존 경로 |
| base | - | 기준 경로, 이에 대해 p 가 상대/근접 경로로 생성됨 |
| ec | - | 오류 상태를 저장할 오류 코드 |
반환값
예외
noexcept
로 표시되지 않은 모든 오버로드는 메모리 할당이 실패할 경우
std::bad_alloc
을(를) throw할 수 있습니다.
예제
#include <filesystem> #include <iostream> void show(std::filesystem::path x, std::filesystem::path y) { std::cout << "x:\t\t " << x << "\ny:\t\t " << y << '\n' << "relative(x, y): " << std::filesystem::relative(x, y) << '\n' << "proximate(x, y): " << std::filesystem::proximate(x, y) << "\n\n"; } int main() { show("/a/b/c", "/a/b"); show("/a/c", "/a/b"); show("c", "/a/b"); show("/a/b", "c"); }
가능한 출력:
x: "/a/b/c" y: "/a/b" relative(x, y): "c" proximate(x, y): "c" x: "/a/c" y: "/a/b" relative(x, y): "../c" proximate(x, y): "../c" x: "c" y: "/a/b" relative(x, y): "" proximate(x, y): "c" x: "/a/b" y: "c" relative(x, y): "" proximate(x, y): "/a/b"
참고 항목
|
(C++17)
|
경로를 나타냄
(클래스) |
|
(C++17)
|
절대 경로를 구성함
(함수) |
|
(C++17)
|
정규 경로를 구성함
(함수) |
|
경로를 정규 형태로 변환함
경로를 상대 형태로 변환함 경로를 근사 형태로 변환함 (
std::filesystem::path
의
public 멤버 함수)
|