twn_skybox.c

This commit is contained in:
2024-09-26 21:02:56 +03:00
parent 0fe1023667
commit c0dcdf8c0a
22 changed files with 268 additions and 13 deletions

View File

@ -253,3 +253,20 @@ bool repeat_ftimer(float *value, float at) {
}
return false;
}
/* TODO: handle utf8 */
char *expand_asterisk(const char *mask, const char *to) {
const char *offset = SDL_strchr(mask, '*');
if (!offset) {
CRY("Invalid path", "Asterisk should be given.");
return NULL;
}
size_t const mask_len = SDL_strlen(mask);
size_t const to_len = SDL_strlen(to);
char *str = SDL_malloc(mask_len + to_len); /* NULL included, replacing the original asterisk */
SDL_memcpy(str, mask, offset - mask);
SDL_memcpy(str + (offset - mask), to, to_len);
SDL_memcpy(str + (offset - mask) + to_len, offset + 1, mask_len - (offset - mask));
str[mask_len + to_len] = '\0';
return str;
}