std::filesystem::last_write_time
std::filesystem::last_write_time (마지막 수정 시간 얻기·변경하기)
경로의 마지막 수정 시간을 얻거나 변경하는 함수예요. C++17부터 있어요.
출처: cppreference
본문
<filesystem> 헤더에 정의돼 있어요.
std::filesystem::file_time_type last_write_time( const std::filesystem::path& p ); // (1) C++17
std::filesystem::file_time_type last_write_time( const std::filesystem::path& p,
std::error_code& ec ) noexcept; // (2) C++17
void last_write_time( const std::filesystem::path& p,
std::filesystem::file_time_type new_time ); // (3) C++17
void last_write_time( const std::filesystem::path& p,
std::filesystem::file_time_type new_time,
std::error_code& ec ) noexcept; // (4) C++17
- 1,2) POSIX
stat의st_mtime멤버에 접근한 것처럼(심볼릭 링크는 따라감)p의 마지막 수정 시간을 돌려줘요. 예외 없는 버전은 오류 시file_time_type::min()을 돌려줘요. - 3,4) POSIX
futimens처럼(심볼릭 링크는 따라감)p의 마지막 수정 시간을 변경해요.
매개변수
p— 검사하거나 수정할 경로new_time— 새 수정 시간ec— 예외 없는 버전에서 오류 보고용 출력 매개변수
반환값
- 1,2)
p의 마지막 수정 시간. - 3,4) (없음)
예외
noexcept로 표시되지 않은 오버로드는 메모리 할당이 실패하면 std::bad_alloc을 던질 수 있어요.
- 1,3) OS API 오류가 있으면
p를 첫 경로 인자, OS 오류 코드를 오류 코드 인자로 삼아std::filesystem::filesystem_error를 던져요. - 2,4) OS API 호출이 실패하면
ec에 OS 오류 코드를 설정하고, 오류가 없다면ec.clear()를 실행해요.