replace_filename(3)
π replace_filename(3) π
okay bestie, so this one is from the Allegro manual β yes, the Allegro game programming library β and it's giving "let me swap out the tail of this path real quick" energy. replace_filename literally replaces a path+filename with a new filename tail. that's it. that's the whole vibe. β¨
β¨ SYNOPSIS β¨
#include <allegro.h>
char *replace_filename(char *dest, const char *path, const char *filename, int size);
πΈ DESCRIPTION πΈ
so what it does is: it takes the path+filename you hand it and swaps in a whole new filename tail, then drops it into the dest buffer β but only ever writes at most size bytes there, so no overflow shenanigans, we love a safe queen π
and here's the iconic part: you can pass the same buffer as both input and output, no cap. like, dest can literally be path. why? because Allegro is a considerate bestie and internally works on a copy of the input before it touches dest, so nothing gets mangled mid-operation. π«Ά
example time, bestie:
char name[200];
...
get_executable_name(name, sizeof(name));
replace_filename(name, name, "sound.dat", sizeof(name));
see how name is doing double duty as both the source and the destination? yeah. slay. π
π RETURN VALUE π
it hands you back a copy of the dest parameter. that's it, that's the return. π
π¦ SEE ALSO π¦
okay that's the whole page, no notes. this was written against Allegro version 4.4.3, and the page itself is replace_filename(3) β so go forth, swap those filenames, and stay hydrated ππ β¨
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms