1 #include "git-compat-util.h"
4 static const char usage_str
[] = "(+|=|=+|=-|-)<seconds> <file>...";
6 int main(int argc
, const char *argv
[])
18 set_eq
= (*timespec
== '=') ? 1 : 0;
21 if (*timespec
== '+') {
22 set_eq
= 2; /* relative "in the future" */
26 set_time
= strtol(timespec
, &test
, 10);
28 fprintf(stderr
, "Not a base-10 integer: %s\n", argv
[1] + 1);
31 if ((set_eq
&& set_time
< 0) || set_eq
== 2) {
32 time_t now
= time(NULL
);
36 for (i
= 2; i
< argc
; i
++) {
40 if (stat(argv
[i
], &sb
) < 0) {
41 fprintf(stderr
, "Failed to stat %s: %s\n",
42 argv
[i
], strerror(errno
));
46 utb
.actime
= sb
.st_atime
;
47 utb
.modtime
= set_eq
? set_time
: sb
.st_mtime
+ set_time
;
49 if (utime(argv
[i
], &utb
) < 0) {
50 fprintf(stderr
, "Failed to modify time on %s: %s\n",
51 argv
[i
], strerror(errno
));
59 fprintf(stderr
, "Usage: %s %s\n", argv
[0], usage_str
);