fix_filename_slashes(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’… fix_filename_slashes β€” the Allegro manual, but make it make sense

okay bestie, welcome to the glow-up era of directory separators ✨ this one lives in the Allegro game programming library, and it's genuinely so useful it's giving main character energy.


✨ NAME ✨

fix_filename_slashes β€” converts all the directory separators to a standard character. Allegro game programming library. no cap. πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

char *fix_filename_slashes(char *path);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie: this function takes the filename chillin' inside path and converts all the directory separators to one standard character. literally all of them. every last one. πŸ’…

which character, you ask? it depends on where you're running:

  • on DOS and Windows platforms, the standard character is a backslash.
  • on most other platforms, it's a slash.

like, it's platform-dependent and it knows what it's doing, trust. 🫢

here's the example, copied exactly so you don't come for me:

char buf[200] = "c:/dos\\backup/weirdo\\test";
...
fix_filename_slashes(buf);
/* Under DOS we would have c:\dos\backup\weirdo\test.
   Under Unix we would have c:/dos/backup/weirdo/test. */

see how chaotic that original string was? slashes AND backslashes just vibing in there all willy-nilly 😭 not anymore. one call and it's unified. iconic behaviour honestly.


⭐ RETURN VALUE ⭐

it returns a copy of the path parameter. that's it. that's the whole return value. short king. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯


ngl, if you're juggling paths from who-knows-where, this is the vibe check your filenames needed. run it before anything else touches that string. periodt. πŸ’–

this page is from Allegro, version 4.4.3, and it's the fix_filename_slashes(3) entry in the manual. mwah, go forth and normalise your separators, bestie πŸ§šπŸ’œ

πŸ“¦ where this page comes from