From bbf4ce91462598cee1eebfb94a773194e56a7ff8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 13:10:31 +0200 Subject: libreplace: always provide utime() and utimes() I'd like to also provide futimes(), but it seems that some systems doesn't support a it at kernel level. If someone knows how to write a portable replacement for futimes() please tell me... metze (This used to be commit a9604fe4a323dccb537cf02ea7594437b4995803) --- source4/lib/replace/replace.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 443da2ab24..2c3f14c2df 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -584,3 +584,30 @@ int rep_unsetenv(const char *name) return 0; } #endif + +#ifndef HAVE_UTIME +int rep_utime(const char *filename, const struct utimbuf *buf) +{ + errno = ENOSYS; + return -1; +} +#endif + +#ifndef HAVE_UTIMES +int rep_utimes(const char *filename, const struct timeval tv[2]) +{ + struct utimbuf u; + + u.actime = tv[0].tv_sec; + if (tv[0].tv_usec > 500000) { + u.actime += 1; + } + + u.modtime = tv[1].tv_sec; + if (tv[1].tv_usec > 500000) { + u.modtime += 1; + } + + return utime(filename, &u); +} +#endif -- cgit