From 1e759cc526eca774db5168eb34601097532b4a2c Mon Sep 17 00:00:00 2001 From: Alexander Borsuk <170263+biodranik@users.noreply.github.com> Date: Thu, 12 Jan 2023 07:55:14 +0100 Subject: [PATCH] [linux] Approximate create time for older Linux versions Signed-off-by: Alexander Borsuk --- platform/platform_linux.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp index 2e4b9fc862..38b2a04b92 100644 --- a/platform/platform_linux.cpp +++ b/platform/platform_linux.cpp @@ -268,8 +268,15 @@ void Platform::GetSystemFontNames(FilesList & res) const // static time_t Platform::GetFileCreationTime(std::string const & path) { +// In older Linux versions there is no reliable way to get file creation time. +#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 28 struct statx st; if (0 == statx(AT_FDCWD, path.c_str(), 0, STATX_BTIME, &st)) return st.stx_btime.tv_sec; +#else + struct stat st; + if (0 == stat(path.c_str(), &st)) + return std::min(st.st_atim.tv_sec, st.st_mtim.tv_sec); +#endif return 0; }