al_get_standard_path(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_get_standard_path πŸ’–

ok so bestie, welcome to the Allegro reference manual (that's the alleg5 era, iconic behavior only). today's main character is al_get_standard_path, and she is literally your plug for finding where on the system stuff is supposed to live. let's get into it 🫢


✨ NAME ✨

al_get_standard_path β€” the Allegro 5 API function that hands you a system path. no cap.


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

ALLEGRO_PATH *al_get_standard_path(int id)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so basically, she gets you a system path, and which one you get depends on the id parameter you pass in. simple as that.

⚠️ but listen: some of these paths may be affected by the organization name</> and application name</>, so be sure to set those before you call this function. like, do it first. don't be out here calling this and then setting names, that's not the vibe. πŸ™ˆ

also, lowkey important: the paths are not guaranteed to be unique (e.g., SETTINGS and DATA may be the same on some platforms), so if you need to avoid naming collisions you should be sure your filenames are unique. and bestie, a returned path may not actually exist on the file system. she's giving hypothetical, not guaranteed real. πŸ’€

here's the whole roster of ids, one by one, no skips:

ALLEGRO_RESOURCES_PATH πŸŽ€

if you bundle data in a location relative to your executable, then you should use this path to locate that data. on most platforms, this is the directory that contains the executable file. periodt.

if called from an OS X app bundle, then this will point to the internal resource directory (<bundle.app>/Contents/Resources). to maintain consistency, if you put your resources into a directory called β€œdata” beneath the executable on some other platform (like Windows), then you should also create a directory called β€œdata” under the OS X app bundle’s resource folder. consistency is the whole point, bestie. ✨

you should not try to write to this path, as it is very likely read-only. hands off, she's not yours. 🚫

if you install your resources in some other system directory (e.g., in /usr/share or C:\ProgramData), then you are responsible for keeping track of that yourself. that's a you problem, respectfully. 🫢

ALLEGRO_TEMP_PATH 🌈

path to the directory for temporary files. temp files! fleeting! like all things. ⭐

ALLEGRO_USER_HOME_PATH 🏠

this is the user’s home directory. you should not normally write files into this directory directly, or create any sub folders in it, without explicit permission from the user. it's their house, bestie, knock first. πŸ™ˆ

one practical application of this path would be to use it as the starting place of a file selector in a GUI. like, cute and respectful use case. πŸ’…

ALLEGRO_USER_DOCUMENTS_PATH πŸ“„

this location is easily accessible by the user, and is the place to store documents and files that the user might want to later open with an external program or transfer to another place.

you should not save files here unless the user expects it, usually by explicit permission. no surprise files in someone's Documents folder, that's giving chaos. 😭

ALLEGRO_USER_DATA_PATH πŸ’Ύ

if your program saves any data that the user doesn’t need to access externally, then you should place it here. this is generally the least intrusive place to store data, so like, the polite option. 🫢

heads up tho: this path will usually not be present on the file system, so make sure to create it before writing to it. she's not there yet, you gotta build her. 🧚

ALLEGRO_USER_SETTINGS_PATH βš™οΈ

if you are saving configuration files (especially if the user may want to edit them outside of your program), then you should place them here. configs deserve their own lil home. ✨

same warning tho: this path will usually not be present on the file system, so make sure to create it before writing to it. πŸ”₯

ALLEGRO_EXENAME_PATH πŸ‘‘

the full path to the executable. that's it. that's the whole thing. slay.


and if it all goes wrong? returns NULL on failure. πŸ’€

the returned path should be freed with al_destroy_path(3alleg5). do NOT forget, bestie, that's a memory leak and we don't do those in this house. πŸŽ€


πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page, bestie!! πŸ’œ this was the Allegro reference manual serving you al_get_standard_path(3alleg5) β€” go forth and path responsibly, ily, bye!! πŸŒΈπŸ’…βœ¨

πŸ“¦ where this page comes from