Switch to utimensat for newer POSIX versions

Some libcs like uClibc-ng can optionally disable deprecated functions.
utime is one of them. When done so, both the header and the function go
missing.

This fixes flac_utime to work in such a situation.
This commit is contained in:
Rosen Penev
2019-08-09 13:01:05 -07:00
committed by Erik de Castro Lopo
parent 5db5820932
commit 66dd7f05d7
5 changed files with 37 additions and 12 deletions

View File

@@ -112,9 +112,13 @@
#include <sys/utime.h> /* for utime() */
#endif
#else
#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
#include <fcntl.h>
#else
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
#include <utime.h> /* for utime() */
#endif
#endif
#if defined _MSC_VER
# if _MSC_VER >= 1800
@@ -160,11 +164,15 @@
#define flac_fopen fopen
#define flac_chmod chmod
#define flac_utime utime
#define flac_unlink unlink
#define flac_rename rename
#define flac_stat stat
#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
#define flac_utime(a, b) utimensat (AT_FDCWD, a, *b, 0)
#else
#define flac_utime utime
#endif
#endif
#ifdef _WIN32