Use glib's g_stat to get file modification time

This commit is contained in:
Marcus Weseloh 2018-04-04 11:03:47 +02:00
parent 7e36bcf058
commit f8bc376392
2 changed files with 8 additions and 7 deletions

View file

@ -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
}

View file

@ -42,6 +42,8 @@
#include <gmodule.h>
#endif
#include <glib/gstdio.h>
/**
* 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