AC_CHECK_HEADERS([string.h strings.h errno.h unistd.h stdio.h stdlib.h])
AC_CHECK_HEADERS([sys/stat.h sys/types.h dirent.h sys/time.h alloca.h])
AC_CHECK_HEADERS([fcntl.h])
+AC_CHECK_HEADERS([utime.h])
AC_SEARCH_LIBS([readdir], [c])
AC_SEARCH_LIBS([strcpy], [c])
AC_SEARCH_LIBS([strstr], [c])
AC_SEARCH_LIBS([memcpy], [c])
+AC_CHECK_FUNCS([utimes])
AC_MSG_CHECKING([for the *time fields in struct stat])
AC_TRY_LINK([
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
#include <sys/time.h>
#include <fcntl.h>
struct dirent *de;
struct stat s;
struct timeval times[2];
+#ifndef HAVE_UTIMES
+ struct utimbuf ub;
+#endif
char *st;
char *tt;
#else
times[1].tv_usec = 0;
#endif
+#ifdef HAVE_UTIMES
if (utimes(trg, times) != 0) {
fprintf(stderr, "failed to set utimes of %s: %s\n",
trg, strerror(errno));
return(-1);
}
+#else
+ ub.actime = s.ATIME_SEC;
+ ub.modtime = s.MTIME_SEC;
+ if(utime(trg, &ub) != 0) {
+ fprintf(stderr, "failed to set utime of %s: %s\n",
+ trg, strerror(errno));
+ return(-1);
+ }
+#endif
} else if (
S_ISLNK(s.st_mode)
)
#else
times[1].tv_usec = 0;
#endif
+#ifdef HAVE_UTIMES
if (utimes(trg, times) != 0) {
fprintf(stderr, "failed to set utimes of %s: %s\n",
trg, strerror(errno));
return(-1);
}
+#else
+ ub.actime = s.ATIME_SEC;
+ ub.modtime = s.MTIME_SEC;
+ if (utime(trg, &ub) != 0) {
+ fprintf(stderr, "failed to set utime of %s: %s\n",
+ trg, strerror(errno));
+ return(-1);
+ }
+#endif
return(0);
}