---
name: "ALLEGRO_FILE_INTERFACE"
section: "3"
platform: "linux"
package: "allegro"
version: "5.2.11.3-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ALLEGRO_FILE_INTERFACE"
---

# ALLEGRO\_FILE\_INTERFACE(3)

Allegro 5 API

## NAME

ALLEGRO\_FILE\_INTERFACE - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro.h>
  typedef struct ALLEGRO_FILE_INTERFACE
  ```

## DESCRIPTION

A structure containing function pointers to handle a type of “file”, real or virtual. See the full discussion in [al\_set\_new\_file\_interface(3)](/al_set_new_file_interface/3.md).

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)](/al_get_file_userdata/3.md) on the file handle. If fi\_open returns NULL then [al\_fopen(3)](/al_fopen/3.md) will also return NULL.

The fi\_fclose function must clean up and free the userdata, but Allegro will free the [ALLEGRO\_FILE(3)](/ALLEGRO_FILE/3.md) handle.

If fi\_fungetc is NULL, then Allegro’s default implementation of a 16 char long buffer will be used.
