refactoring done, small bugfixes included, vectors and lists of non-primitive types are not working though

This commit is contained in:
Odweta
2024-02-05 00:16:25 +01:00
parent 8832a2a4aa
commit e40b61a21b
9 changed files with 631 additions and 797 deletions
+17 -16
View File
@@ -2,38 +2,39 @@
#define FILE_H
#include <odweta/vector.h>
#include <odweta/util.h>
typedef struct {
char* path; // the file descriptor
char *path; // the file descriptor
int length; // line count
vector_t* lines; // 2d array of chars
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
file_t *file_new(char *path); // initialization function
void fileCleanup(file_t* f); // just to be memory safe...
void file_cleanup(file_t *this); // just to be memory safe...
void filePrint(file_t* f); // prints the file as a string
void file_print(file_t *this); // prints the file as a string
char* fileToString(file_t* f); // returns a string with the file contents
char *file_to_string(file_t *this); // 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 file_writeln(file_t *this, 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!)
void file_write(file_t *this, char *payload); // appends a given string to the file (not on a newline!)
void fileCopy(file_t* src, char* dst); // copy file src into file dst
void file_copy(file_t* src, char *dst); // copy file src into file dst
void fileDelete(file_t* f); // deletes a file
void file_delete(file_t *this); // deletes a file
void fileMove(file_t* src, char* dst); // moves/renames a file
void file_move(file_t* src, char *dst); // moves/renames a file
int fileExists(file_t* f); // 1 = yes, 0 = no
bool file_exists(file_t *this); // 1 = yes, 0 = no
void fileCreateEmpty(char* path); // create an empty file with the given name
void file_create(char *path); // create an empty file with the given name
void fileNumberLines(file_t* f); // prepend line numbers in front of each line in a file
void file_number_lines(file_t *this); // prepend line numbers in front of each line in a file
int fileCountWords(file_t* f); // counts the number of words in a file
int file_count_words(file_t *this); // counts the number of words in a file
#endif
#endif // FILE_H