Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::filesystem::file_time_type

      From cppreference.com
      <cpp‎ |experimental‎ |fs
       
       
       
      Filesystem library
      Classes
      Functions
      File types
       
      Defined in header<experimental/filesystem>
      using file_time_type= chrono::time_point</*trivial-clock*/>;
      (filesystem TS)

      Represents file time.trivial-clock is an implementation-defined type that satisfiesTrivialClock and is sufficient to represent the resolution and range of the file time values offered by the filesystem.

      [edit]Example

      Run this code
      #include <chrono>#include <experimental/filesystem>#include <fstream>#include <iomanip>#include <iostream>namespace fs= std::experimental::filesystem;usingnamespace std::chrono_literals; int main(){    fs::path p= fs::current_path()/"example.bin";std::ofstream(p.c_str()).put('a');// create fileauto ftime= fs::last_write_time(p); std::time_t cftime= decltype(ftime)::clock::to_time_t(ftime);// assuming system_clockstd::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

      [edit]See also

      gets or sets the time of the last data modification
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/fs/file_time_type&oldid=103097"

      [8]ページ先頭

      ©2009-2025 Movatter.jp