scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 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
 9int
10setstat(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}