This commit is contained in:
Odweta
2023-12-21 13:31:10 +01:00
parent eb6b6c8343
commit 784fd0d35d
3 changed files with 34 additions and 51 deletions
+12 -8
View File
@@ -2,23 +2,27 @@
#define FILE_H
#include <odweta/vector.h>
#include <stdio.h>
typedef struct {
FILE* descriptor; // the file descriptor
char* path; // 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 :(
file_t* fileInit(char* path); // initialization function
void fileCleanup(file_t* f); // just to be memory safe...
int fileCountLines(file_t* f); //
int fileCountLines(file_t* f); // counts the lines in a file
void filePrint(file_t* f);
void filePrint(file_t* f); // prints the file as a string
char* fileToString(file_t* f);
char* fileToString(file_t* f); // returns a string with the file contents
#endif
void fileWriteln(file_t* f, char* line); // appends a given string to the file on a newline
void fileWrite(file_t* f, char* line); // appends a given string to the file (not on a newline!)
void fileClear(file_t* f); // wipes the file contents
#endif