twn_util.c: add file_read()

This commit is contained in:
veclavtalica
2025-02-20 19:51:52 +03:00
parent e15975bfaa
commit a231d650f2
6 changed files with 39 additions and 64 deletions

View File

@ -154,6 +154,24 @@ char *file_to_str(const char *path) {
return str_out;
}
static char **read_files;
char const *file_read(char const *file) {
char *s = file_to_str(file);
if (s) arrpush(read_files, s);
return s;
}
void file_read_garbage_collect(void) {
for (size_t i = 0; i < arrlenu(read_files); ++i)
SDL_free(read_files[i]);
arrfree(read_files);
read_files = NULL;
}
bool file_exists(const char *path) {
return PHYSFS_exists(path);