std::filesystem:: absolute
|
헤더 파일에 정의됨
<filesystem>
|
||
|
path absolute
(
const
std::
filesystem
::
path
&
p
)
;
|
(1) | (C++17부터) |
|
path absolute
(
const
std::
filesystem
::
path
&
p,
std::
error_code
&
ec
)
;
|
(2) | (C++17부터) |
p 가 참조하는 파일 시스템 위치와 동일한 경로를 반환하며, 이 경로에 대해 filesystem::path::is_absolute() 가 true 인 경우입니다.
목차 |
매개변수
| p | - | 절대 형태로 변환할 경로 |
| ec | - | non-throwing 오버로드에서 오류 보고를 위한 출력 매개변수 |
반환값
p 가 참조하는 동일한 파일을 가리키는 절대(반드시 정규화된 것은 아닌) 경로명을 반환합니다.
예외
noexcept
로 표시되지 않은 모든 오버로드는 메모리 할당이 실패할 경우
std::bad_alloc
을(를) throw할 수 있습니다.
참고 사항
구현체는 p 가 존재하지 않는 것을 오류로 간주하지 않는 것이 권장됩니다.
POSIX 기반 운영 체제의 경우, std :: filesystem :: absolute ( p ) 는 std:: filesystem :: current_path ( ) / p 와 동일합니다. 단, p 가 빈 경로인 경우는 예외입니다.
Windows의 경우,
std::filesystem::absolute
는
GetFullPathNameW
호출로 구현될 수 있습니다.
예제
#include <filesystem> #include <iostream> namespace fs = std::filesystem; int main() { std::filesystem::path p = "foo.c"; std::cout << "Current path is " << std::filesystem::current_path() << '\n'; std::cout << "Absolute path for " << p << " is " << fs::absolute(p) << '\n'; }
가능한 출력:
Current path is "/tmp/1666297965.0051296" Absolute path for "foo.c" is "/tmp/1666297965.0051296/foo.c"
참고 항목
|
(C++17)
|
정규 경로를 구성함
(함수) |
|
(C++17)
|
상대 경로를 구성함
(함수) |