/* * Various filesystem utilities. */ #pragma once #include #include #define WITH_FILE(FILEPATH, BODY) \ { \ assert(FILEPATH); \ FILE* file = fopen(FILEPATH, "rb"); \ if (file) { \ BODY; \ fclose(file); \ } \ } /// Get the file's size. size_t get_file_size(const char* filename); /// Get the file's size. size_t get_file_size_f(FILE* file); /// Read the entire contents of the file into memory. void* read_file(const char* filepath); /// Read the entire contents of the file into memory. /// /// The given buffer must be large enough to hold the file's contents. bool read_file_f(FILE*, void* buffer);