---
name: "al_for_each_fs_entry"
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/al_for_each_fs_entry"
---

# al\_for\_each\_fs\_entry(3)

Allegro 5 API

## NAME

al\_for\_each\_fs\_entry - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro.h>
  int al_for_each_fs_entry(ALLEGRO_FS_ENTRY *dir,
                           int (*callback)(ALLEGRO_FS_ENTRY *dir, void *extra),
                           void *extra)
  ```

## DESCRIPTION

This function takes the [ALLEGRO\_FS\_ENTRY(3)](/ALLEGRO_FS_ENTRY/3.md) `dir`, which should represent a directory, and looks for any other file system entries that are in it. This function will then call the callback function `callback` once for every filesystem entry in the directory `dir`.

The callback `callback` must be of type `int callback(ALLEGRO_FS_ENTRY * entry, void * extra)`. The `callback` will be called with a pointer to an [ALLEGRO\_FS\_ENTRY(3)](/ALLEGRO_FS_ENTRY/3.md) that matches one file or directory in `dir`, and the pointer passed in the `extra` parameter to [al\_for\_each\_fs\_entry(3)](/al_for_each_fs_entry/3.md).

When `callback` returns `ALLEGRO_FOR_EACH_FS_ENTRY_STOP` or `ALLEGRO_FOR_EACH_FS_ENTRY_ERROR`, iteration will stop immediately and [al\_for\_each\_fs\_entry(3)](/al_for_each_fs_entry/3.md) will return the value the `callback` returned.

When `callback` returns `ALLEGRO_FOR_EACH_FS_ENTRY_OK` iteration will continue normally, and if the [ALLEGRO\_FS\_ENTRY(3)](/ALLEGRO_FS_ENTRY/3.md) parameter of `callback` is a directory, [al\_for\_each\_fs\_entry(3)](/al_for_each_fs_entry/3.md) will call itself on that directory. Therefore the function will recusively descend into that directory.

However, when `callback` returns `ALLEGRO_FOR_EACH_FS_ENTRY_SKIP` iteration will continue, but [al\_for\_each\_fs\_entry(3)](/al_for_each_fs_entry/3.md) will NOT recurse into the [ALLEGRO\_FS\_ENTRY(3)](/ALLEGRO_FS_ENTRY/3.md) parameter of `callback` even if it is a directory.

This function will skip any files or directories named `.` or `..` which may exist on certain platforms and may signify the current and the parent directory. The `callback` will not be called for files or directories with such a name.

Returns ALLEGRO\_FOR\_EACH\_FS\_ENTRY\_OK if successful, or ALLEGRO\_FOR\_EACH\_FS\_ENTRY\_ERROR if something went wrong in processing the directory. In that case it will use [al\_set\_errno(3)](/al_set_errno/3.md) to indicate the type of error which occurred. This function returns ALLEGRO\_FOR\_EACH\_FS\_ENTRY\_STOP in case iteration was stopped by making `callback` return that value. In this case, [al\_set\_errno(3)](/al_set_errno/3.md) will not be used.

## SEE ALSO

[ALLEGRO\_FOR\_EACH\_FS\_ENTRY\_RESULT(3)](/ALLEGRO_FOR_EACH_FS_ENTRY_RESULT/3.md)

## SINCE

5\.1.9
