14 std::string path =
basePath + filePath;
15 FILE* file = fopen(filePath.c_str(),
"rb");
26 fseek(file, 0, SEEK_END);
27 u32 size = ftell(file);
42 void* buffer = malloc(size);
45 fread(buffer, 1, size, file);
74 std::string directPath =
basePath + path + suffix;
76 FILE* file = fopen(directPath.c_str(),
"rb");
83 size_t end = path.find_last_not_of(
'/');
84 if (end == std::string::npos)
89 size_t slash = path.find_last_of(
'/', end);
91 path.substr(slash == std::string::npos ? 0 : slash + 1, end - (slash == std::string::npos ? 0 : slash + 1) + 1);
92 return path.substr(0, end + 1) +
"/" + leaf + suffix;
98 std::string path =
basePath + filePath;
99 FILE* file = fopen(path.c_str(),
"rb");
106 fseek(file, 0, SEEK_END);
107 u32 size = ftell(file);
116 void* buffer = malloc(size);
119 fread(buffer, 1, size, file);
133 std::string path =
basePath + filePath;
134 FILE* file = fopen(path.c_str(),
"rb");
140 fseek(file, 0, SEEK_END);
150 void* buffer = malloc(size);
153 fread(buffer, 1, size, file);
Manager for IO functions.
Owns a heap-allocated file buffer and its length.
void * loadToRAM(const std::string &filePath, u32 *outSize)
Loads an entire file into a buffer.
FileBuffer openFileBuffer(const std::string &path)
void unloadFromRAM(void *buffer)
Releases a buffer previously returned by loadToRAM().
void * openFile(const std::string &path)
Open a file and return a pointer to its contents.
std::string getAssetFilePath(const std::string &path, const char *suffix)
Resolves the on-disk path for an asset, allowing it to be stored either as a flat file or grouped in ...
void logMessage(LogSeverity severity, std::string_view message, std::source_location location)
Logs a diagnostic message and halts only for fatal messages.
Util to handle error logging.