← cproj

open close read file

d4cc75f4191e5c7d5dcd01d9822f4afff8e60f20 · ovidiucs · Jun 28, 2019 21:29

+30 −1 · 1 file changed

  • mylib/src/myhash.c +30 −1
diff --git a/mylib/src/myhash.c b/mylib/src/myhash.c
index b761679..8bad99e 100644
--- a/mylib/src/myhash.c
+++ b/mylib/src/myhash.c
@@ -3,9 +3,14 @@
 #include <string.h>
 #include "../include/myhash.h"
 #include "../include/mylib.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
-#define DEFAULT_HASH_SIZE 97
 
+#define DEFAULT_HASH_SIZE 97
+#define PATH_MAX 255
+#define BUFF 1024
 //  Free allocated memory for entire hash table
 #if 0
 void h_free (HashNode *hash) {
@@ -176,3 +181,27 @@ void h_delete (HashTable *hTable, char *key) {
    * (HashNode **) $83 = 0x00005555555592a8
 	 */
 }
+void openFile (const char *fn) {
+		// Return value for open()
+		int inputFd;
+		// Output fd
+		int outputFd = 2; // stderr
+		// buffer
+
+		inputFd = open(fn,O_RDONLY);
+
+}
+
+void readFile (int fd) {
+	// Read bytes from fd int numRead for read () 3rd arg
+	ssize_t numRead;
+	// Set buffer for void *buf arg
+	char buf[BUFF];
+	while( (numRead = read (fd, buf, BUFF) > 0) {
+
+	}
+}
+
+void closeFile(fd){
+
+}