From d9ad63f9331f7d804c4978a644272810e200eb4c Mon Sep 17 00:00:00 2001 From: Jason Summers Date: Sat, 13 Jun 2026 07:36:57 -0400 Subject: [PATCH] Try to fix macOS builds (st_mtim/st_atim related) Ref: https://github.com/jsummers/deark/pull/110 Co-authored-by: Daeho Ro <40587651+daeho-ro@users.noreply.github.com> Upstream-Status: Backport [https://github.com/jsummers/deark/commit/d9ad63f9331f7d804c4978a644272810e200eb4c] --- src/deark-config.h | 16 ++++++++++++++++ src/deark-unix.c | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/deark-config.h b/src/deark-config.h index b827795a..2d225af5 100644 --- src/deark-config.h.orig +++ src/deark-config.h @@ -54,6 +54,22 @@ #define _TIME_BITS 64 #endif +#ifndef DE_USE_MTIMENSEC +#if defined(__APPLE__) +#define DE_USE_MTIMENSEC 1 +#else +#define DE_USE_MTIMENSEC 0 +#endif +#endif + +#ifndef DE_USE_MTIM +#if (_POSIX_C_SOURCE >= 200809L) && (!DE_USE_MTIMENSEC) +#define DE_USE_MTIM 1 +#else +#define DE_USE_MTIM 0 +#endif +#endif + #ifndef DE_USE_FSEEKO #define DE_USE_FSEEKO 1 #endif diff --git a/src/deark-unix.c b/src/deark-unix.c index b60d2398..2472649f 100644 --- src/deark-unix.c.orig +++ src/deark-unix.c @@ -77,7 +77,14 @@ static int de_examine_file_by_fd(struct de_fopen_params *fop, int fd) fop->len = (i64)stbuf.st_size; -#if _POSIX_C_SOURCE >= 200809L +#if DE_USE_MTIMENSEC + de_unix_time_to_timestamp(stbuf.st_mtime, &fop->orig_modtime, 0); + de_timestamp_set_subsec(&fop->orig_modtime, + (double)stbuf.st_mtimensec/1000000000.0); + de_unix_time_to_timestamp(stbuf.st_atime, &fop->orig_acctime, 0); + de_timestamp_set_subsec(&fop->orig_acctime, + (double)stbuf.st_atimensec/1000000000.0); +#elif DE_USE_MTIM de_unix_time_to_timestamp(stbuf.st_mtim.tv_sec, &fop->orig_modtime, 0); de_timestamp_set_subsec(&fop->orig_modtime, (double)stbuf.st_mtim.tv_nsec/1000000000.0); -- 2.55.0