std::filesystem::file_time_type (3) - Linux Manuals
std::filesystem::file_time_type: std::filesystem::file_time_type
Command to display std::filesystem::file_time_type
manual in Linux: $ man 3 std::filesystem::file_time_type
NAME
std::filesystem::file_time_type - std::filesystem::file_time_type
Synopsis
Defined in header <filesystem>
using file_time_type = std::chrono::time_point</*trivial-clock*/>; (since C++17)
(until C++20)
using file_time_type = std::chrono::time_point<std::chrono::file_clock>; (since C++20)
Represents file time.
trivial-clock is an implementation-defined type that satisfies TrivialClock and is sufficient to represent the resolution and range of the file time values offered by the filesystem. (until C++20)
Example
// Run this code
#include <iostream>
#include <chrono>
#include <iomanip>
#include <fstream>
#include <filesystem>
namespace fs = std::filesystem;
using namespace std::chrono_literals;
int main()
{
fs::path p = fs::current_path() / "example.bin";
std::ofstream(p.c_str()).put('a'); // create file
auto ftime = fs::last_write_time(p);
// assuming system_clock for this demo
// note: not true on MSVC or GCC 9; C++20 will allow portable output
std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
std::cout << "File write time is " << std::asctime(std::localtime(&cftime)) << '\n';
fs::last_write_time(p, ftime + 1h); // move file write time 1 hour to the future
ftime = fs::last_write_time(p); // read back from the filesystem
cftime = decltype(ftime)::clock::to_time_t(ftime);
std::cout << "File write time is " << std::asctime(std::localtime(&cftime)) << '\n';
fs::remove(p);
}
Possible output:
File write time is Tue Mar 31 19:47:04 2015
File write time is Tue Mar 31 20:47:04 2015
See also
last_write_time gets or sets the time of the last data modification
(function)
(C++17)
Pages related to std::filesystem::file_time_type
- std::filesystem::file_type (3) - std::filesystem::file_type
- std::filesystem::file_size (3) - std::filesystem::file_size
- std::filesystem::file_status (3) - std::filesystem::file_status
- std::filesystem::file_status::file_status (3) - std::filesystem::file_status::file_status
- std::filesystem::file_status::operator= (3) - std::filesystem::file_status::operator=
- std::filesystem::file_status::permissions (3) - std::filesystem::file_status::permissions
- std::filesystem::file_status::type (3) - std::filesystem::file_status::type
- std::filesystem::filesystem_error (3) - std::filesystem::filesystem_error
- std::filesystem::filesystem_error::filesystem_error (3) - std::filesystem::filesystem_error::filesystem_error
- std::filesystem::filesystem_error::path1,std::filesystem::filesystem_error::path2 (3) - std::filesystem::filesystem_error::path1,std::filesystem::filesystem_error::path2
- std::filesystem::filesystem_error::what (3) - std::filesystem::filesystem_error::what
- std::filesystem::absolute (3) - std::filesystem::absolute
- std::filesystem::begin(directory_iterator),std::filesystem::end(directory_iterator) (3) - std::filesystem::begin(directory_iterator),std::filesystem::end(directory_iterator)
- std::filesystem::begin(recursive_directory_iterator), (3) - std::filesystem::begin(recursive_directory_iterator),
- std::filesystem::begin(recursive_directory_iterator),std::filesystem::end(recursive_directory_iterator) (3) - std::filesystem::begin(recursive_directory_iterator),std::filesystem::end(recursive_directory_iterator)
- std::filesystem::canonical,std::filesystem::weakly_canonical (3) - std::filesystem::canonical,std::filesystem::weakly_canonical
- std::filesystem::copy (3) - std::filesystem::copy
- std::filesystem::copy_file (3) - std::filesystem::copy_file
- std::filesystem::copy_options (3) - std::filesystem::copy_options
- std::filesystem::copy_symlink (3) - std::filesystem::copy_symlink
- std::filesystem::create_directory,std::filesystem::create_directories (3) - std::filesystem::create_directory,std::filesystem::create_directories