initial commit

This commit is contained in:
Odweta
2023-12-07 20:03:18 +01:00
commit 7fb1267224
8 changed files with 722 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#ifndef FILE_H
#define FILE_H
#include <odweta/vector.h>
#include <stdio.h>
typedef struct {
FILE* descriptor; // the file descriptor
int length; // line count
vector_t* lines; // 2d array of chars
} file_t;
file_t* fileInit(char* path, char* mode); // initialization function
// TODO: when there is not a '\n' at the end of a file, the last line is not loaded :(
void fileCleanup(file_t* f); // just to be memory safe...
int fileCountLines(file_t* f); //
void filePrint(file_t* f);
char* fileToString(file_t* f);
#endif