Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice03 / ex3.c
diff options
context:
space:
mode:
Commitb50c86bd91351bfde316a4aa6e06e95588e4553f (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-12-02 19:57:42 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-12-02 19:57:42 +0200
Filesb783c0ff51ab2c0d0166d136ee91ffb358863b23 /Year 3/System programming/Practice03/ex3.c
uni-projects-b50c86bd91351bfde316a4aa6e06e95588e4553f.tar
uni-projects-b50c86bd91351bfde316a4aa6e06e95588e4553f.tar.gz
uni-projects-b50c86bd91351bfde316a4aa6e06e95588e4553f.zip
Parent54bc74f4bcc80a9f3c874db16c43b6b1cd07d3e1 (diff)
[SP/P03] Solved exercises
1 files changed, 17 insertions, 0 deletions
-rw-r--r--Year 3/System programming/Practice03/ex3.c17
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;
+ }
+}