for_each_file_ex(3)
π for_each_file_ex(3) π
Allegro manual, bestie!! We're about to loop over files like it's nothing π¦β¨
β¨ NAME β¨
for_each_file_ex β executes callback() for each file matching a wildcard. It's giving Allegro game programming library π
π¦ SYNOPSIS π¦
#include <allegro.h>
int for_each_file_ex(const char *name, int in_attrib, int out_attrib,
int (*callback)(const char *filename, int attrib, void *param), void
*param);
π DESCRIPTION π
Okay so this function finds all the files on disk that match the wildcard spec and file attributes you give it, and it runs callback() once for each one. Lowkey, it's a convenient wrapper around al_findfirst(), al_findnext(), and al_findclose(). in_attrib is a bitmask for the attributes the files must carry; out_attrib is a bitmask for the attributes the files must not carry. Attributes that aren't specified in either bitmask are literally not taken into account when deciding whether callback() gets invoked or not. Periodt.
The callback function gets three arguments: the first is a string containing the completed filename (exactly the same string you passed to for_each_file_ex() but with meta characters), the second is the actual attributes of the file, and the third is a void pointer that is simply a copy of param β you can use it for whatever you like, no rules π«Ά. The callback must return zero to let the enumeration proceed, or any non-zero value to stop it. If an error occurs, the error code will be stored in errno, but the enumeration won't stop. Iconic, honestly.
Example:
int show_name(const char *filename, int attrib, void *param)
{
allegro_message("Caught `%s', attribs %d\n",
filename, attrib);
return 0;
}
...
count = for_each_file_ex("data/level*", FA_DIREC,
0, show_name, 0);
allegro_message("%d game directories\n", count);
π RETURN VALUE π
Returns the number of successful calls made to callback(), that is, the number of times callback() was called and returned 0. Slay β¨
π SEE ALSO π
Allegro manual, version 4.4.3, for_each_file_ex(3) β bye bestie, go enumerate some files π
ππΈ
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms