diff options
author | Rosen Penev <rosenp@gmail.com> | 2019-08-09 13:01:05 -0700 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2019-08-20 06:49:13 +1000 |
commit | 66dd7f05d7dc973f8ce55d24ebcc88447242d4e5 (patch) | |
tree | a445ecde661703d39ee0373696a689e23ac1f780 /src/share/grabbag | |
parent | 5db58209329b722529ec74f9b4f36bf367145835 (diff) | |
download | flac-66dd7f05d7dc973f8ce55d24ebcc88447242d4e5.tar.gz |
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.
Diffstat (limited to 'src/share/grabbag')
-rw-r--r-- | src/share/grabbag/file.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/share/grabbag/file.c b/src/share/grabbag/file.c index 2c67bebf..5f3bc4ef 100644 --- a/src/share/grabbag/file.c +++ b/src/share/grabbag/file.c @@ -27,7 +27,6 @@ #include <fcntl.h> /* for _O_BINARY */ #else #include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */ -#include <utime.h> /* for utime() */ #endif #if defined __EMX__ #include <io.h> /* for setmode(), O_BINARY */ @@ -53,11 +52,17 @@ void grabbag__file_copy_metadata(const char *srcpath, const char *destpath) { struct flac_stat_s srcstat; - struct utimbuf srctime; if(0 == flac_stat(srcpath, &srcstat)) { +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) + struct timespec srctime[2] = {}; + srctime[0].tv_sec = srcstat.st_atime; + srctime[1].tv_sec = srcstat.st_mtime; +#else + struct utimbuf srctime; srctime.actime = srcstat.st_atime; srctime.modtime = srcstat.st_mtime; +#endif (void)flac_chmod(destpath, srcstat.st_mode); (void)flac_utime(destpath, &srctime); } |