twn_skybox.c
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user