From: Alan Cox Date: Fri, 2 Jan 2015 22:41:02 +0000 (+0000) Subject: utimes: Add utimes as a wrapper around utime X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=dbfa2924feb107249f1594ecd3adc7755f8e4b08;p=FUZIX.git utimes: Add utimes as a wrapper around utime --- diff --git a/Library/include/sys/time.h b/Library/include/sys/time.h index 948d42a9..12a12ca1 100644 --- a/Library/include/sys/time.h +++ b/Library/include/sys/time.h @@ -3,7 +3,6 @@ #include -#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); diff --git a/Library/libs/Makefile b/Library/libs/Makefile index 9433c8e0..d19f9891 100644 --- a/Library/libs/Makefile +++ b/Library/libs/Makefile @@ -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 index 00000000..7967cf67 --- /dev/null +++ b/Library/libs/utimes.c @@ -0,0 +1,16 @@ +/* + * Fake utimes with utime. Our fs resolution is 1 second so its fine + */ + +#include +#include + +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