Allow to compile on Interix which only has utime, original patch by markus.duft at...
authorFabian Groffen <grobian@gentoo.org>
Mon, 5 Nov 2007 20:46:22 +0000 (20:46 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 5 Nov 2007 20:46:22 +0000 (20:46 -0000)
svn path=/main/branches/prefix/; revision=8433

configure.in
src/chpathtool.c

index f7b4987a9fcff5799cf6a0914cc5618915a45e1a..d927225da492aac39d12ff57af12c15f69f73a44 100644 (file)
@@ -51,11 +51,13 @@ AC_HEADER_STDC
 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([
index 04a170a3492c1fe599dc25858cad2de8b2f42b5c..54f3fe45d4d42442037d09dddba94f5bb38ae918 100644 (file)
@@ -24,6 +24,9 @@
 #ifdef HAVE_ALLOCA_H
 #include <alloca.h>
 #endif
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
 #include <sys/time.h>
 #include <fcntl.h>
 
@@ -167,6 +170,9 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
        struct dirent *de;
        struct stat s;
        struct timeval times[2];
+#ifndef HAVE_UTIMES
+       struct utimbuf ub;
+#endif
        char *st;
        char *tt;
 
@@ -268,11 +274,21 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
 #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)
                                )
@@ -350,11 +366,21 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
 #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);
 }