GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::filesystem::file_time_type(3) C++ Standard Libary std::filesystem::file_time_type(3)

std::filesystem::file_time_type - std::filesystem::file_time_type


Defined in header <filesystem>
using file_time_type = std::chrono::time_point</*trivial-clock*/>; (since C++17)
(until C++20)
using file_time_type = (since C++20)
std::chrono::time_point<std::chrono::file_clock>;


Represents file time.


trivial-clock is an implementation-defined type that satisfies
TrivialClock and is sufficient to represent the resolution and range (until C++20)
of the file time values offered by the filesystem.

// Run this code


#include <chrono>
#include <filesystem>
#include <format>
#include <fstream>
#include <iostream>


using namespace std::chrono_literals;


int main()
{
auto p = std::filesystem::temp_directory_path() / "example.bin";
std::ofstream(p.c_str()).put('a'); // create file


std::filesystem::file_time_type ftime = std::filesystem::last_write_time(p);
std::cout << std::format("File write time is {}\n", ftime);


std::filesystem::last_write_time(p, ftime + 1h); // move file write time 1 hour to the future
ftime = std::filesystem::last_write_time(p); // read back from the filesystem
std::cout << std::format("File write time is {}\n", ftime);


std::filesystem::remove(p);
}


File write time is Sun May 9 23:29:58 2021
File write time is Mon May 10 00:29:58 2021


last_write_time gets or sets the time of the last data modification
(C++17) (function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.