Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the equivalent of std::filesystem::last_write_time() for the file's creation time?

I'm using c++17 and std::filesystem::last_write_time already, but now I also need the file creation time, and there doesn't seem to be an API for that in std::filesystem. Did I miss it? If not, how come there isn't one?

Do I have to resort to non-portable code to extract that creation timestamp? Does Boost. File system, the ancestor of std::filesystem, have such an API?

like image 265
ddevienne Avatar asked Aug 04 '21 16:08

ddevienne


Video Answer


1 Answers

I don't think it exists in C++17.

Boost contains boost::filesystem::creation_time since version 1.75.0 (December 2020). If you don't want to depend on Boost and only care about some platforms, you could use their implementation for inspiration.

Note that creation time is inherently non-portable; although some filesystems do record creation times, POSIX doesn't specify it. Whether this is the reason why C++17 doesn't implement it is anyone's guess.

like image 110
Thomas Avatar answered Oct 23 '22 15:10

Thomas