#ifndef FILE_H #define FILE_H #include #include 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 *file_new(char *path); // initialization function void file_cleanup(file_t *this); // just to be memory safe... void file_print(file_t *this); // prints the file as a string char *file_to_string(file_t *this); // returns a string with the file contents void file_writeln(file_t *this, char *payload); // appends a given string to the file on a newline void file_write(file_t *this, char *payload); // appends a given string to the file (not on a newline!) void file_copy(file_t* src, char *dst); // copy file src into file dst void file_delete(file_t *this); // deletes a file void file_move(file_t* src, char *dst); // moves/renames a file bool file_exists(file_t *this); // 1 = yes, 0 = no void file_create(char *path); // create an empty file with the given name void file_number_lines(file_t *this); // prepend line numbers in front of each line in a file int file_count_words(file_t *this); // counts the number of words in a file #endif // FILE_H