1 #include "lib.h" 2 #include <sys/types.h> 3 #include <time.h> 4 #include <utime.h> 5 #include <errno.h> 6 #include <stdlib.h> 7 #include "sys9.h" 8 #include "dir.h" 9 10 int 11 utime(const char *path, const struct utimbuf *times) 12 { 13 int n; 14 Dir *d; 15 time_t curt; 16 17 if((d = _dirstat(path)) == nil){ 18 _syserrno(); 19 return -1; 20 } 21 if(times == 0) { 22 curt = time(0); 23 d->atime = curt; 24 d->mtime = curt; 25 } else { 26 d->atime = times->actime; 27 d->mtime = times->modtime; 28 } 29 n = _dirwstat(path, d); 30 if(n < 0) 31 _syserrno(); 32 free(d); 33 return n; 34 } 35