fix_filename_slashes(3alleg4)

πŸ’… fix_filename_slashes β€” Allegro manual, bestie edition

okay so you're reading the Allegro manual and you landed on fix_filename_slashes, which is genuinely one of the most useful lil functions in the whole game programming library. she's a 3alleg4 girlie and she's here to fix your slashes. no cap.


✨ NAME ✨

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


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

char *fix_filename_slashes(char *path);

🌸 DESCRIPTION 🌸

okay so picture this: you've got a filename sitting in path, and the directory separators in it are a whole mess β€” some slashes, some backslashes, chaos, it's giving unhinged. this function converts all of them to one standard character. periodt. πŸ’…

which character is "standard" depends on where you are:

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

and here's the example, verbatim, because I would never mess with your code bestie:

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. */

look at her go 🧚 one call and every separator is matching. iconic behaviour fr fr.


πŸ’– RETURN VALUE πŸ’–

returns a copy of the path parameter. that's it. that's the whole vibe. 🫢


πŸ‘‘ SEE ALSO πŸ‘‘


lowkey obsessed with how simple this one is. no gotchas, no footguns, just slashes getting their life together ✨

so yeah bestie, that's the whole page 🌈 this was Allegro, version 4.4.3, and fix_filename_slashes(3alleg4) is out here doing the lord's work one separator at a time. go fix some paths, you got this πŸ’œπŸŒΈπŸ’