std::filesystem::filesystem_error:: path1, std::filesystem::filesystem_error:: path2
From cppreference.net
<
cpp
|
filesystem
|
filesystem error
C++
filesystem_error
| Member functions | ||||
|
filesystem_error::path1
filesystem_error::path2
|
||||
| Inherited from std::system_error | ||||
|
const
std::
filesystem
::
path
&
path1
(
)
const
noexcept
;
|
(C++17 이후) | |
|
const
std::
filesystem
::
path
&
path2
(
)
const
noexcept
;
|
(C++17 이후) | |
예외 객체에 저장된 경로들을 반환합니다.
매개변수
(없음)
반환값
생성자가 저장한
path
매개변수 사본에 대한 참조입니다.
예제
이 코드 실행
#include <cstdio> #include <filesystem> #include <iostream> int main() { const std::filesystem::path old_p{std::tmpnam(nullptr)}, new_p{std::tmpnam(nullptr)}; try { std::filesystem::rename(old_p, new_p); // old_p가 존재하지 않으므로 예외 발생 } catch(std::filesystem::filesystem_error const& ex) { std::cout << "what(): " << ex.what() << '\n' << "path1(): " << ex.path1() << '\n' << "path2(): " << ex.path2() << '\n'; } }
가능한 출력:
what(): filesystem error: cannot rename: No such file or directory [/tmp/fileIzzRLB] [/tmp/fileiUDWlV] path1(): "/tmp/fileIzzRLB" path2(): "/tmp/fileiUDWlV"