#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#if ((!defined(HAVE_UTIMENSAT) && defined(HAVE_LUTIMES)) || \
+ (!defined(HAVE_FUTIMENS) && defined(HAVE_FUTIMES)))
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#endif
#include <archive.h>
#include <archive_entry.h>
int mode;
struct timespec mtime;
struct stat sb;
- struct timespec ts[2];
int fd, check, text;
const char *linkname;
+#if defined(HAVE_UTIMENSAT) || defined(HAVE_FUTIMENS)
+ struct timespec ts[2];
+#endif
+#if ((!defined(HAVE_UTIMENSAT) && defined(HAVE_LUTIMES)) || \
+ (!defined(HAVE_FUTIMENS) && defined(HAVE_FUTIMES)))
+ struct timeval times[2];
+#endif
mode = archive_entry_mode(e) & 0777;
if (mode == 0)
return;
}
+#if defined(HAVE_UTIMENSAT) || defined(HAVE_FUTIMENS)
ts[0].tv_sec = 0;
ts[0].tv_nsec = UTIME_NOW;
ts[1] = mtime;
+#endif
+#if ((!defined(HAVE_UTIMENSAT) && defined(HAVE_LUTIMES)) || \
+ (!defined(HAVE_FUTIMENS) && defined(HAVE_FUTIMES)))
+ times[0].tv_sec = 0;
+ times[0].tv_usec = -1;
+ times[1].tv_sec = mtime.tv_sec;
+ times[1].tv_usec = mtime.tv_nsec / 1000;
+#endif
/* process symlinks */
linkname = archive_entry_symlink(e);
warning("Cannot set mode for '%s'", *path);
#endif
/* set access and modification time */
+#if defined(HAVE_UTIMENSAT)
if (utimensat(AT_FDCWD, *path, ts, AT_SYMLINK_NOFOLLOW) != 0)
warning("utimensat('%s')", *path);
+#elif defined(HAVE_LUTIMES)
+ gettimeofday(×[0], NULL);
+ if (lutimes(*path, times) != 0)
+ warning("lutimes('%s')", *path);
+#endif
return;
}
info("\n");
/* set access and modification time */
+#if defined(HAVE_FUTIMENS)
if (futimens(fd, ts) != 0)
error("futimens('%s')", *path);
+#elif defined(HAVE_FUTIMES)
+ gettimeofday(×[0], NULL);
+ if (futimes(fd, times) != 0)
+ error("futimes('%s')", *path);
+#endif
if (close(fd) != 0)
error("close('%s')", *path);
}