ALLEGRO_FILE_INTERFACE(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

✨ NAME ✨

ALLEGRO_FILE_INTERFACE β€” Allegro 5 API, bestie. This page is from the Library Functions Manual, and it’s literally the struct that tells Allegro how to handle a β€œfile.”

🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

typedef struct ALLEGRO_FILE_INTERFACE

πŸ’– DESCRIPTION πŸ’–

Okay so picture a structure containing function pointers to handle a type of β€œfile” β€” real or virtual, no cap. The full discussion lives in al_set_new_file_interface(3), so go read that too, bestie.

The fields are:

void*         (*fi_fopen)(const char *path, const char *mode);
bool          (*fi_fclose)(ALLEGRO_FILE *f);
size_t        (*fi_fread)(ALLEGRO_FILE *f, void *ptr, size_t size);
size_t        (*fi_fwrite)(ALLEGRO_FILE *f, const void *ptr, size_t size);
bool          (*fi_fflush)(ALLEGRO_FILE *f);
int64_t       (*fi_ftell)(ALLEGRO_FILE *f);
bool          (*fi_fseek)(ALLEGRO_FILE *f, int64_t offset, int whence);
bool          (*fi_feof)(ALLEGRO_FILE *f);
int           (*fi_ferror)(ALLEGRO_FILE *f);
const char *  (*fi_ferrmsg)(ALLEGRO_FILE *f);
void          (*fi_fclearerr)(ALLEGRO_FILE *f);
int           (*fi_fungetc)(ALLEGRO_FILE *f, int c);
off_t         (*fi_fsize)(ALLEGRO_FILE *f);

The fi_open function must allocate memory for whatever userdata structure it needs. The pointer to that memory must be returned; it will then be associated with the file. The other functions can access that data by calling al_get_file_userdata(3) on the file handle. If fi_open returns NULL then al_fopen(3) will also return NULL.

The fi_fclose function must clean up and free the userdata, but Allegro will free the ALLEGRO_FILE(3) handle. Slay, but that’s the split, bestie.

If fi_fungetc is NULL, then Allegro’s default implementation of a 16 char long buffer will be used. Iconic default behavior, honestly. ✨


Source/version: Allegro reference manual. Date: not listed in the footer on this page, so I’m not inventing one, bestie. Bye! πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms