summaryrefslogtreecommitdiff
path: root/src/share/grabbag/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/grabbag/file.c')
-rw-r--r--src/share/grabbag/file.c9
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);
}