From f8bc376392e14eb7b98951bbdd5ee735785c6764 Mon Sep 17 00:00:00 2001 From: Marcus Weseloh Date: Wed, 4 Apr 2018 11:03:47 +0200 Subject: [PATCH] Use glib's g_stat to get file modification time --- src/sfloader/fluid_samplecache.c | 9 ++------- src/utils/fluid_sys.h | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/sfloader/fluid_samplecache.c b/src/sfloader/fluid_samplecache.c index b86f4368..adb7f7a9 100644 --- a/src/sfloader/fluid_samplecache.c +++ b/src/sfloader/fluid_samplecache.c @@ -267,18 +267,13 @@ static fluid_samplecache_entry_t *get_samplecache_entry(SFData *sf, static int fluid_get_file_modification_time(char *filename, time_t *modification_time) { -#if defined(WIN32) || defined(__OS2__) - *modification_time = 0; - return FLUID_OK; -#else - struct stat buf; + fluid_stat_buf_t buf; - if (stat(filename, &buf) == -1) + if (fluid_stat(filename, &buf)) { return FLUID_FAILED; } *modification_time = buf.st_mtime; return FLUID_OK; -#endif } diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h index 13c0b7ff..787f5992 100644 --- a/src/utils/fluid_sys.h +++ b/src/utils/fluid_sys.h @@ -42,6 +42,8 @@ #include #endif +#include + /** * Macro used for safely accessing a message from a GError and using a default * message if it is NULL. @@ -355,6 +357,10 @@ void fluid_socket_close(fluid_socket_t sock); fluid_istream_t fluid_socket_get_istream(fluid_socket_t sock); fluid_ostream_t fluid_socket_get_ostream(fluid_socket_t sock); +/* File access */ +typedef GStatBuf fluid_stat_buf_t; +#define fluid_stat(_filename, _statbuf) g_stat((_filename), (_statbuf)) + /* Profiling */ #if WITH_PROFILING