new demo
This commit is contained in:
+12
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user