From dad302a3a72978f64fd428fe9a5be747283be0da Mon Sep 17 00:00:00 2001
From: "iliya.saroukha" <iliya.saroukha@hes-so.ch>
Date: Thu, 1 Jun 2023 11:51:06 +0200
Subject: [PATCH] working on close

---
 struct/lib_fs.c | 13 ++++++++++---
 test_lib.c      |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/struct/lib_fs.c b/struct/lib_fs.c
index 81c4eb2..13b3754 100644
--- a/struct/lib_fs.c
+++ b/struct/lib_fs.c
@@ -1,11 +1,18 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
 #include "lib_fs.h"
 
-// int copy(char *src, char *dst, unsigned int buf_size)
-// {
+int copy(char *src, char *dst, unsigned int buf_size)
+{
+    int fd_src = open(src, O_RDONLY);
+    int fd_dst = open(dst, O_WRONLY | O_CREAT, 0640);
 
-// }
+    close(fd_src);
+    close(fd_dst);
+}
 
 int copyf(char *src, char *dst, unsigned int buf_size)
 {
diff --git a/test_lib.c b/test_lib.c
index c8ae3f7..67798a0 100644
--- a/test_lib.c
+++ b/test_lib.c
@@ -15,7 +15,7 @@ int main(int argc, char **argv)
     char *src = "./src.txt";
     char *dst = "./dst.txt";
 
-    fprintf(stdout, "\nNumber of bytes copied: %d\n", copyf(src, dst, atoi(argv[1])));
+    fprintf(stdout, "\ncopyf(char %s, char %s, unsigned int %d)\tNumber of bytes copied: %d\n", src, dst, atoi(argv[1]), copyf(src, dst, atoi(argv[1])));
 
     return EXIT_SUCCESS;
 }
-- 
GitLab