From 53bb2a6ad13b70df013229591103b85a7420d27a Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Tue, 9 Jul 2024 22:12:39 +0200 Subject: [PATCH] Fix uptime on MacOS On MacOS the birth time is apparently not available so we use modification time instead. --- src/fs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fs.c b/src/fs.c index 6a2063c..740d9a0 100644 --- a/src/fs.c +++ b/src/fs.c @@ -199,7 +199,6 @@ double fs_get_creation_time(const char *path) double fs_get_creation_time(const char *path) { - // Use stat on macOS to access creation time struct stat st; if (stat(path, &st) != 0) @@ -207,7 +206,7 @@ double fs_get_creation_time(const char *path) return -1; } - return st.st_birthtimespec.tv_sec + st.st_birthtimespec.tv_nsec / 1e9; + return st.st_mtimespec.tv_sec + st.st_mtimespec.tv_nsec / 1e9; } #else