Files
odwetalibc/include/file.h
T
2023-12-07 20:03:18 +01:00

24 lines
569 B
C

#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