al_set_physfs_file_interface(3alleg5)

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

πŸ’– NAME πŸ’–

al_set_physfs_file_interface β€” it's giving "switch the whole file vibe over to PhysicsFS", and it's part of the Allegro 5 API bestie πŸŽ€


✨ SYNOPSIS ✨

#include <allegro5/allegro_physfs.h>

void al_set_physfs_file_interface(void)

🌸 DESCRIPTION 🌸

Okay so. This function sets both the ALLEGRO_FILE_INTERFACE(3alleg5) and the ALLEGRO_FS_INTERFACE(3alleg5) β€” and not just for the whole program, no no, it does it for the calling thread. Very main-character, very "I'm the one making decisions around here" πŸ’…

After you call it, any subsequent calls to al_fopen(3alleg5) on the calling thread get handled by PHYSFS_open(). Slay. And every operation on the files that come back from al_fopen(3alleg5) gets performed through PhysicsFS too. It's a whole pipeline, fr fr πŸ¦‹

Calls to the Allegro filesystem functions β€” think al_read_directory(3alleg5) or al_create_fs_entry(3alleg5) β€” on the calling thread? Yeah, those get diverted to PhysicsFS. No cap. They don't go to Allegro's own filesystem layer anymore.

Now if you wanna remember and restore another file I/O backend (because sometimes you gotta switch back, and that's valid 🌈), you can use al_store_state(3alleg5) / al_restore_state(3alleg5). Save that state, bestie, like a screenshot of your outfit before you change πŸŽ€

Note: due to an oversight 😭 this function differs from al_set_new_file_interface(3alleg5) and al_set_standard_file_interface(3alleg5), which only alter the current ALLEGRO_FILE_INTERFACE(3alleg5). So yeah β€” this one is doing more than its cousins. Not me pointing out the family drama πŸ’€
Note: PhysFS does not support text-mode reading and writing. Which means Windows-style newlines will not be preserved. They're just… gone. Sorry babe πŸ™ˆ

🫢 SEE ALSO 🫢


Okay that's the whole page, you ate it, you understood it, you're iconic for reading the docs πŸ’–

This came out of the Allegro reference manual, filed under al_set_physfs_file_interface(3alleg5) β€” go off, and stan the manual βœ¨πŸ“š

πŸ“¦ where this page comes from