utimes: Add utimes as a wrapper around utime
authorAlan Cox <alan@linux.intel.com>
Fri, 2 Jan 2015 22:41:02 +0000 (22:41 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 2 Jan 2015 22:41:02 +0000 (22:41 +0000)
Library/include/sys/time.h
Library/libs/Makefile
Library/libs/utimes.c [new file with mode: 0644]

index 948d42a..12a12ca 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <time.h>
 
-#ifdef _BSD_SOURCE
 
 typedef unsigned long suseconds_t;
 
@@ -12,6 +11,10 @@ struct timeval {
   suseconds_t tv_usec;
 };
 
+extern int utimes(const char *filename, const struct timeval times[2]);
+
+#ifdef _BSD_SOURCE
+
 extern int gettimeofday(struct timeval *tv, struct timezone *tz);
 extern int settimeofday(struct timeval *tv, const struct timezone *tz);
 
index 9433c8e..d19f989 100644 (file)
@@ -32,7 +32,7 @@ SRC_C += setvbuf.c settimeofday.c sleep.c sprintf.c stat.c stdio0.c
 SRC_C += strcasecmp.c strdup.c stricmp.c strlcpy.c strncasecmp.c
 SRC_C += strnicmp.c strsep.c
 SRC_C += strtod.c strtol.c system.c time.c tmpnam.c ttyname.c
-SRC_C += tzset.c ungetc.c utent.c utsname.c
+SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c
 SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c
 SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c
 # tty layer
diff --git a/Library/libs/utimes.c b/Library/libs/utimes.c
new file mode 100644 (file)
index 0000000..7967cf6
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ *     Fake utimes with utime. Our fs resolution is 1 second so its fine
+ */
+
+#include <sys/time.h>
+#include <utime.h>
+
+int utimes(const char *filename, const struct timeval times[2])
+{
+  struct utimbuf u;
+  if (times == NULL)  
+    return utime(filename, NULL);
+  u.actime = times[0].tv_sec;
+  u.modtime = times[0].tv_usec;
+  return utime(filename, &u);
+}
\ No newline at end of file