Files
odwetalibc/include/file.h
T

26 lines
737 B
C

#ifndef FILE_H
#define FILE_H
#include <odweta/vector.h>
typedef struct {
char* path; // the file descriptor
int length; // line count
vector_t* lines; // 2d array of chars
int not_newline_terminated; // bool: 1 = true, 0 = false
} file_t;
file_t* fileInit(char* path); // initialization function
void fileCleanup(file_t* f); // just to be memory safe...
void filePrint(file_t* f); // prints the file as a string
char* fileToString(file_t* f); // returns a string with the file contents
void fileWriteln(file_t* f, char* payload); // appends a given string to the file on a newline
void fileWrite(file_t* f, char* payload); // appends a given string to the file (not on a newline!)
#endif