feat(state): save state on exiting

This commit is contained in:
2025-11-02 13:37:34 +01:00
parent 1835050079
commit 09e04720f1
9 changed files with 113 additions and 7 deletions
+22
View File
@@ -75,6 +75,28 @@ File file_read(char *path) {
return file;
}
void file_write(char *path, ConstStringArray lines) {
unsigned int i;
FILE *file_pointer;
log_info("Writing %s...", path);
// open file
file_pointer = fopen(path, "w");
if (file_pointer == NULL) {
log_warn("Cannot open file '%s'", path);
return;
}
// write file
for (i = 0; i < lines.length; i++) {
fprintf(file_pointer, "%s\n", lines.values[i]);
}
// close file
fclose(file_pointer);
}
void file_prepend(File *src, File extra) {
char *old_src_content;