ALLEGRO_FS_INTERFACE(3alleg5)

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

πŸ’– NAME πŸ’–

okay bestie, welcome to ALLEGRO_FS_INTERFACE β€” the Allegro 5 API page that's literally all about the filesystem interface. yes, that one. the one that makes your files go ✨. (this is page 3alleg5, in case you were wondering which manual you wandered into 🫢)


✨ SYNOPSIS ✨

first things first, you gotta bring it in:

#include <allegro5/allegro.h>

typedef struct ALLEGRO_FS_INTERFACE ALLEGRO_FS_INTERFACE;

that's it. that's the vibe. ALLEGRO_FS_INTERFACE is a struct, you don't poke at its guts, you just hand it the function pointers and let it cook. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: this is the whole menu of functions you can provide for a filesystem. like, if you're building your own filesystem backend, these are the slots you fill in. no cap.

here's every single one, and yes we're listing all of them because none of them are skippable:

                 ALLEGRO_FS_ENTRY *  fs_create_entry   (const char *path);
                 void                fs_destroy_entry  (ALLEGRO_FS_ENTRY *e);
                 const char *        fs_entry_name     (ALLEGRO_FS_ENTRY *e);
                 bool                fs_update_entry   (ALLEGRO_FS_ENTRY *e);
                 uint32_t            fs_entry_mode     (ALLEGRO_FS_ENTRY *e);
                 time_t              fs_entry_atime    (ALLEGRO_FS_ENTRY *e);
                 time_t              fs_entry_mtime    (ALLEGRO_FS_ENTRY *e);
                 time_t              fs_entry_ctime    (ALLEGRO_FS_ENTRY *e);
                 off_t               fs_entry_size     (ALLEGRO_FS_ENTRY *e);
                 bool                fs_entry_exists   (ALLEGRO_FS_ENTRY *e);
                 bool                fs_remove_entry   (ALLEGRO_FS_ENTRY *e);
  • fs_create_entry β€” makes a brand new ALLEGRO_FS_ENTRY * from a const char *path. new entry, who dis πŸ’…
  • fs_destroy_entry β€” takes an ALLEGRO_FS_ENTRY *e and cleans it up. give it a lil goodbye kiss πŸŽ€
  • fs_entry_name β€” hands you back the name as a const char *. it's giving "what's your name bestie"
  • fs_update_entry β€” refreshes the entry, returns a bool. glow-up time ✨
  • fs_entry_mode β€” the mode, as a uint32_t
  • fs_entry_atime β€” access time, as a time_t
  • fs_entry_mtime β€” modification time, as a time_t
  • fs_entry_ctime β€” change time, as a time_t
  • fs_entry_size β€” size, as an off_t
  • fs_entry_exists β€” does it exist? bool. vibe check 🫢
  • fs_remove_entry β€” yeets the entry, returns a bool

and then the directory squad, because folders are also main characters:

                 bool                fs_open_directory (ALLEGRO_FS_ENTRY *e);
                 ALLEGRO_FS_ENTRY *  fs_read_directory (ALLEGRO_FS_ENTRY *e);
                 bool                fs_close_directory(ALLEGRO_FS_ENTRY *e);
  • fs_open_directory β€” opens up a directory entry, returns a bool
  • fs_read_directory β€” reads out of it and gives you an ALLEGRO_FS_ENTRY *. iconic.
  • fs_close_directory β€” closes it back up, returns a bool

then the path-based besties, working straight off strings:

                 bool                fs_filename_exists(const char *path);
                 bool                fs_remove_filename(const char *path);
                 char *              fs_get_current_directory(void);
                 bool                fs_change_directory(const char *path);
                 bool                fs_make_directory(const char *path);
  • fs_filename_exists β€” is there a file at this const char *path? bool. another vibe check πŸ”
  • fs_remove_filename β€” deletes whatever's at const char *path, returns a bool
  • fs_get_current_directory β€” takes void, gives you back a char * with where you're currently at πŸ“
  • fs_change_directory β€” moves you to the const char *path, returns a bool
  • fs_make_directory β€” makes a new directory at const char *path, returns a bool. nesting era 🌸

and last but never least, the file opener:

                 ALLEGRO_FILE *      fs_open_file(ALLEGRO_FS_ENTRY *e);
  • fs_open_file β€” takes an ALLEGRO_FS_ENTRY *e and gives you back an ALLEGRO_FILE *. the grand finale, the moment, the πŸ’… periodt.
fr fr, that's the entire interface. don't skip any of them, the filesystem needs all of its little guys.

and that's the page bestie, you ate it πŸ’– this was pulled from the Allegro reference manual, page ALLEGRO_FS_INTERFACE(3alleg5) β€” go build something cute with it, ily, mwah 😭🫢

πŸ“¦ where this page comes from