problems with al_findfirst
I'm trying to do a simple search and list files in a directory. This is my code and for some reason it doesn't find any files:
what am I doing wrong?
Try specifying an absolute path, IE: "C:\*.htm", also, keep in mind these don't search recursively, so if you have folders IN whichever folder you're running this, it won't work properly.
What almost everyone does wrong :
al_findfirst(search_criteria.c_str(), &info, 0)
By passing 0, you are exclusing all files that have any attributes set (keep reading http://alleg.sourceforge.net/onlinedocs/en/alleg030.html until this makes sense). Pass FA_ALL instead (this is not documented in the 4.2 documentation due to an oversight, it is in SVN). The SVN documentation also has a less confusing description of what the flags do than the one in the current documentation.
Thread #554228. Printed from Allegro.cc
Ah, twas the example in the documentation. FA_ALL is not diclared in the version I'm using - 4.2.0(beta3). so I did this:
#define FA_ALL FA_RDONLY | FA_HIDDEN | FA_SYSTEM | FA_LABEL | FA_DIREC | FA_ARCH
(any I missed?)
on a different note:
I've been using the online manual from allegro.cc, the last paragraph is doubled on some of these al_find* entries.