1for_each_file_ex(3)             Allegro manual             for_each_file_ex(3)
2
3
4

NAME

6       for_each_file_ex  -  Executes callback() for each file matching a wild‐
7       card. Allegro game programming library.
8

SYNOPSIS

10       #include <allegro.h>
11
12
13       int for_each_file_ex(const char *name, int in_attrib,  int  out_attrib,
14       int  (*callback)(const  char  *filename, int attrib, void *param), void
15       *param);
16

DESCRIPTION

18       Finds all the files on disk which match the given  wildcard  specifica‐
19       tion  and file attributes, and executes callback() once for each. Basi‐
20       cally, this is a convenient  wrapper  around  al_findfirst(),  al_find‐
21       next()  and  al_findclose().  `in_attrib'  is  a bitmask specifying the
22       attributes the files must carry, `out_attrib' is a  bitmask  specifying
23       the attributes the files must not carry; attributes which are not spec‐
24       ified in either bitmasks  are  not  taken  into  account  for  deciding
25       whether callback() is invoked or not.
26
27       The  callback  function  will be passed three arguments: the first is a
28       string which contains the completed filename (exactly the  same  string
29       you  passed to for_each_file_ex() but with meta characters), the second
30       is the actual attributes of the file, and the third is a  void  pointer
31       which  is  simply  a copy of `param' (you can use this for whatever you
32       like). The callback must return zero to let the enumeration proceed, or
33       any  non-zero value to stop it. If an error occurs, the error code will
34       be stored in `errno' but the enumeration won't stop. Example:
35
36          int show_name(const char *filename, int attrib, void *param)
37          {
38             allegro_message("Caught `%s', attribs %d\n",
39                             filename, attrib);
40             return 0;
41          }
42          ...
43             count = for_each_file_ex("data/level*", FA_DIREC,
44                                      0, show_name, 0);
45             allegro_message("%d game directories\n", count);
46

RETURN VALUE

48       Returns the number of successful calls made to callback(), that is, the
49       number of times callback() was called and returned 0.
50
51

SEE ALSO

53       al_findfirst(3), al_findnext(3), al_findclose(3)
54
55
56
57Allegro                          version 4.4.2             for_each_file_ex(3)
Impressum