1al_for_each_fs_entry(3) al_for_each_fs_entry(3)
2
3
4
6 al_for_each_fs_entry - Allegro 5 API
7
9 #include <allegro5/allegro.h>
10
11 int al_for_each_fs_entry(ALLEGRO_FS_ENTRY *dir,
12 int (*callback)(ALLEGRO_FS_ENTRY *dir, void *extra),
13 void *extra)
14
16 This function takes the ALLEGRO_FS_ENTRY(3) dir, which should represent
17 a directory, and looks for any other file system entries that are in
18 it. This function will then call the callback function callback once
19 for every filesystem entry in the directory dir.
20
21 The callback callback must be of type int callback(ALLEGRO_FS_EN‐
22 TRY * entry, void * extra). The callback will be called with a pointer
23 to an ALLEGRO_FS_ENTRY(3) that matches one file or directory in dir,
24 and the pointer passed in the extra parameter to al_for_each_fs_en‐
25 try(3).
26
27 When callback returns ALLEGRO_FOR_EACH_FS_ENTRY_STOP or ALLE‐
28 GRO_FOR_EACH_FS_ENTRY_ERROR, iteration will stop immediately and
29 al_for_each_fs_entry(3) will return the value the callback returned.
30
31 When callback returns ALLEGRO_FOR_EACH_FS_ENTRY_OK iteration will con‐
32 tinue normally, and if the ALLEGRO_FS_ENTRY(3) parameter of callback is
33 a directory, al_for_each_fs_entry(3) will call itself on that directo‐
34 ry. Therefore the function will recusively descend into that directo‐
35 ry.
36
37 However, when callback returns ALLEGRO_FOR_EACH_FS_ENTRY_SKIP iteration
38 will continue, but al_for_each_fs_entry(3) will NOT recurse into the
39 ALLEGRO_FS_ENTRY(3) parameter of callback even if it is a directory.
40
41 This function will skip any files or directories named . or .. which
42 may exist on certain platforms and may signify the current and the par‐
43 ent directory. The callback will not be called for files or directo‐
44 ries with such a name.
45
46 Returns ALLEGRO_FOR_EACH_FS_ENTRY_OK if successful, or ALLE‐
47 GRO_FOR_EACH_FS_ENTRY_ERROR if something went wrong in processing the
48 directory. In that case it will use al_set_errno(3) to indicate the
49 type of error which occurred. This function returns ALLE‐
50 GRO_FOR_EACH_FS_ENTRY_STOP in case iteration was stopped by making
51 callback return that value. In this case, al_set_errno(3) will not be
52 used.
53
55 ALLEGRO_FOR_EACH_FS_ENTRY_RESULT(3)
56
58 5.1.9
59
60
61
62Allegro reference manual al_for_each_fs_entry(3)