make_relative_filename(3alleg4)
π make_relative_filename β the Allegro manual page, bestie edition π
okay so this is make_relative_filename from the Allegro manual, and it's genuinely one of those little functions that just works once you get it. She tries to make a relative filename from an absolute path and filename. slay.
β¨ NAME β¨
make_relative_filename β tries to make a relative filename from absolute path and filename. Allegro game programming library. π
πΈ SYNOPSIS πΈ
#include <allegro.h>
char *make_relative_filename(char *dest, const char *path, const char
*filename, int size);
π¦ DESCRIPTION π¦
so basically, she attempts to make a relative filename from an absolute path and an absolute filename, storing at most size bytes into the dest buffer. π
real talk: this function won't work if the paths are not canonical under the current platform (seecanonicalize_filename()). also,destcannot be used as input value forpathorfilename. not me warning you twice, it's just important bestie π
example, because seeing it is believing:
char base[] = "/long/absolute/path/program.exe";
char user_input[] = "/nice/and/short.txt";
...
make_relative_filename(buf, base, user_input, sizeof(buf));
/* Under Unix buf would contain:
../../../nice/and/short.txt */
like, look at that glow-up. absolute path in, cute little relative path out. iconic. β¨
π RETURN VALUE π
returns a copy of the dest parameter if she succeeds, or NULL if she fails (eg. under DOS, one path starts with "C:\" and another with "A:\"). periodt. π
π SEE ALSO π
and that's the whole page, bestie β brought to you by Allegro version 4.4.3, make_relative_filename(3alleg4), mwah π go make some relative paths, you got this π«Ά
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms