touch.c (912B)
1 /* ISC license. */ 2 3 #include <skalibs/sysdeps.h> 4 5 #ifdef SKALIBS_HASFUTIMENS 6 7 #include <skalibs/nonposix.h> 8 #include <time.h> 9 #include <sys/stat.h> 10 #include <skalibs/djbunix.h> 11 #include <skalibs/posixplz.h> 12 13 int touch (char const *file) 14 { 15 int r ; 16 int fd = open_create(file) ; 17 if (fd < 0) return 0 ; 18 r = futimens(fd, 0) >= 0 ; 19 fd_close(fd) ; 20 return r ; 21 } 22 23 #else 24 #ifdef SKALIBS_HASFUTIMES 25 26 #include <skalibs/nonposix.h> 27 #include <sys/time.h> 28 #include <skalibs/djbunix.h> 29 #include <skalibs/posixplz.h> 30 31 int touch (char const *file) 32 { 33 int r ; 34 int fd = open_create(file) ; 35 if (fd < 0) return 0 ; 36 r = futimes(fd, 0) >= 0 ; 37 fd_close(fd) ; 38 return r ; 39 } 40 41 #else 42 43 #include <sys/time.h> 44 #include <skalibs/djbunix.h> 45 #include <skalibs/posixplz.h> 46 47 int touch (char const *file) 48 { 49 int fd = open_create(file) ; 50 if (fd < 0) return 0 ; 51 fd_close(fd) ; 52 return utimes(file, 0) >= 0 ; 53 } 54 55 #endif 56 #endif