get_filename(3)
π get_filename β bestie edition π
okay so this is a page from the Allegro manual, the game programming library, and we're talking about get_filename(3) β the little function that hands you a pointer to the filename part of a path. π
β¨ NAME β¨
get_filename β returns a pointer to the filename portion of a path. it's giving Allegro game programming library realness π¦
πΈ SYNOPSIS πΈ
#include <allegro.h>
char *get_filename(const char *path);
π DESCRIPTION π
so what this does is: it finds the filename portion of a completely specified file path. like, full path in, filename out. iconic.
now here's the tea on separators β both \ and / count as directory separators when you're under DOS and Windows. but under every other platform? only / counts. so no cap, the backslash thing is a Windows/DOS-only situation. π
example, look:
get_executable_name(name, sizeof(name));
allegro_message("Running `%s'\n", get_filename(name));
β¨ important note: Allegro does not perform any IO operations during the verification. none. zero. it's just vibing with the string.
and the way that matters is: if you have /a/path/like/this/ β which doesn't have a filename β the function returns a pointer to the trailing null character. but if you have /a/path/like/this (no trailing slash), Allegro returns a pointer to this, even if it is a valid directory. no peeking at the filesystem, no checking if it's real, just vibes. π
π«Ά RETURN VALUE π«Ά
returns a pointer to the portion of path where the filename starts β or the beginning of path if no valid filename is found (eg. you are processing a path with backslashes under Unix, which lowkey will not work for you there bestie π).
π SEE ALSO π
and that's the whole page, periodt. π
β¨ this was Allegro, version 4.4.3 β shoutout to the Allegro girlies for keeping the docs alive, ily, go read get_extension(3) next bestie ππ¦πΈ
π¦ 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