twn_util: file_read() with :exists

This commit is contained in:
veclavtalica
2025-03-10 05:34:29 +03:00
parent 48e3a4c233
commit 8ed8158ae6
2 changed files with 6 additions and 1 deletions

View File

@ -177,7 +177,7 @@ String file_read(char const *file, char const *operation) {
return s;
}
if (SDL_strncmp(operation, ":binary", sizeof (":binary") - 1) == 0) {
else if (SDL_strncmp(operation, ":binary", sizeof (":binary") - 1) == 0) {
uint8_t *data;
int64_t length = file_to_bytes(file, &data);
@ -189,6 +189,10 @@ String file_read(char const *file, char const *operation) {
return s;
} else if (SDL_strncmp(operation, ":exists", sizeof (":exists") - 1) == 0) {
bool exists = file_exists(file);
return exists ? (String){"yes", 3} : (String){"no", 2};
} else
log_warn("No valid operation specified by %s", operation);