dirwstat.c - 9base - revived minimalist port of Plan 9 userland to Unix
 (HTM) git clone git://git.suckless.org/9base
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       dirwstat.c (504B)
       ---
            1 #include <u.h>
            2 #define NOPLAN9DEFINES
            3 #include <libc.h>
            4 #include <sys/time.h>
            5 #include <utime.h>
            6 #include <sys/stat.h>
            7 
            8 int
            9 dirwstat(char *file, Dir *dir)
           10 {
           11         int ret;
           12         struct utimbuf ub;
           13 
           14         /* BUG handle more */
           15         ret = 0;
           16         if(~dir->mode != 0){
           17                 if(chmod(file, dir->mode) < 0)
           18                         ret = -1;
           19         }
           20         if(~dir->mtime != 0){
           21                 ub.actime = dir->mtime;
           22                 ub.modtime = dir->mtime;
           23                 if(utime(file, &ub) < 0)
           24                         ret = -1;
           25         }
           26         if(~dir->length != 0){
           27                 if(truncate(file, dir->length) < 0)
           28                         ret = -1;
           29         }
           30         return ret;
           31 }