std::experimental::filesystem:: file_time_type
From cppreference.net
<
cpp
|
experimental
|
fs
C++
Experimental
| Technical Specification | ||||
| Filesystem library (filesystem TS) | ||||
| Library fundamentals (library fundamentals TS) | ||||
| Library fundamentals 2 (library fundamentals TS v2) | ||||
| Library fundamentals 3 (library fundamentals TS v3) | ||||
| Extensions for parallelism (parallelism TS) | ||||
| Extensions for parallelism 2 (parallelism TS v2) | ||||
| Extensions for concurrency (concurrency TS) | ||||
| Extensions for concurrency 2 (concurrency TS v2) | ||||
| Concepts (concepts TS) | ||||
| Ranges (ranges TS) | ||||
| Reflection (reflection TS) | ||||
| Mathematical special functions (special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
Filesystem library
| Classes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<experimental/filesystem>
|
||
|
using
file_time_type
=
chrono
::
time_point
<
/*trivial-clock*/
>
;
|
(filesystem TS) | |
ファイル時間を表します。
trivial-clock
は
TrivialClock
を満たす実装定義の型であり、ファイルシステムが提供するファイル時間値の分解能と範囲を表現するのに十分です。
例
このコードを実行
#include <chrono> #include <experimental/filesystem> #include <fstream> #include <iomanip> #include <iostream> namespace fs = std::experimental::filesystem; using namespace std::chrono_literals; int main() { fs::path p = fs::current_path() / "example.bin"; std::ofstream(p.c_str()).put('a'); // ファイルを作成 auto ftime = fs::last_write_time(p); std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime); // system_clockを仮定 std::cout << "File write time is " << std::asctime(std::localtime(&cftime)) << '\n'; fs::last_write_time(p, ftime + 1h); // ファイルの最終更新時刻を1時間未来に移動 ftime = fs::last_write_time(p); // ファイルシステムから再読み込み cftime = decltype(ftime)::clock::to_time_t(ftime); std::cout << "File write time is " << std::asctime(std::localtime(&cftime)) << '\n'; fs::remove(p); }
出力例:
File write time is Tue Mar 31 19:47:04 2015 File write time is Tue Mar 31 20:47:04 2015
関連項目
|
最終データ更新時刻を取得または設定する
(関数) |