setstat-posix.c - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
       setstat-posix.c (408B)
       ---
            1 #include <sys/stat.h>
            2 #include <unistd.h>
            3 #include <utime.h>
            4 
            5 #include <time.h>
            6 
            7 #include <scc/scc.h>
            8 
            9 int
           10 setstat(char *fname, struct fprop *prop)
           11 {
           12         struct utimbuf ut = {prop->time, prop->time};
           13 
           14         if (chown(fname, prop->uid, prop->gid) < 0) {
           15                 if (chown(fname, getuid(), getgid()) < 0)
           16                         return -1;
           17         }
           18         if (chmod(fname, prop->mode) < 0)
           19                 return -1;
           20         if (utime(fname, &ut) < 0)
           21                 return -1;
           22         return 0;
           23 }