From: Fabian Groffen Date: Mon, 5 Nov 2007 20:46:22 +0000 (-0000) Subject: Allow to compile on Interix which only has utime, original patch by markus.duft at... X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=4d51fc91d2fbab1fe14b98da0a0e65f9b2d4f0da;p=portage.git Allow to compile on Interix which only has utime, original patch by markus.duft at salomon.at in bug #198180 svn path=/main/branches/prefix/; revision=8433 --- diff --git a/configure.in b/configure.in index f7b4987a9..d927225da 100644 --- a/configure.in +++ b/configure.in @@ -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([ diff --git a/src/chpathtool.c b/src/chpathtool.c index 04a170a34..54f3fe45d 100644 --- a/src/chpathtool.c +++ b/src/chpathtool.c @@ -24,6 +24,9 @@ #ifdef HAVE_ALLOCA_H #include #endif +#ifdef HAVE_UTIME_H +#include +#endif #include #include @@ -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); }