twn_util: file_read() with :exists
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user