diff options
[SP/P03] Solved exercises
1 files changed, 17 insertions, 0 deletions
| -rw-r--r-- | Year 3/System programming/Practice03/ex3.c | 17 |
diff --git a/Year 3/System programming/Practice03/ex3.c b/Year 3/System programming/Practice03/ex3.c new file mode 100644 index 0000000..45019bd --- /dev/null +++ b/Year 3/System programming/Practice03/ex3.c @@ -0,0 +1,17 @@ +#include <sys/stat.h> +#include <utime.h> // struct utimbuf, utime +#include <stdio.h> // perror + +int main(int argc, char* argv[]) { + struct stat buf; + if(stat(argv[1], &buf) < 0) { + perror("stat"); + return 1; + } + + struct utimbuf newtime = { buf.st_atime - 60 * 60 * 1, buf.st_mtime + 60 * 1 }; + if (utime(argv[1], &newtime) < 0) { + perror("utime"); + return 2; + } +} |
