file_select_ex
ngiacomelli

I'm using file_select_ex as a directory selection tool. Which is pretty silly, but I'm not that bothered. file_select_ex still passes me the directory path, but only if the user clicks the CANCEL button. I'm not looking to distribute this, so for the time being, I'm happy with that functionality.

Ultimately, what I want to do is search through a directory and find every file in that particular directory. There may be easier ways to do this, or even a way to trigger a Win32 directory selection box.

Really, I'm looking for advice on how to correctly search a folder using al_findfirst, al_findnext, and al_findclose.

1int GUIRunTrace(void) {
2
3 int GUILoadWindow;
4 char path[100] = "c:/";
5 struct al_ffblk info;
6
7 GUILoadWindow = file_select_ex("Select Directory...", path, "+d", sizeof(path), 420, 340);
8 
9 if ( !GUILoadWindow ) {
10
11 if (al_findfirst("*.*", &info, 0) != 0)
12 return;
13 
14 do {
15 allegro_message("%s", info.name);
16 } while (al_findnext(&info) == 0);
17 
18 al_findclose(&info);
19
20 }
21
22 return GUILoadWindow;
23
24}

CGamesPlay

You forgot to ask a question.

ngiacomelli
Quote:

Ultimately, what I want to do is search through a directory and find every file in that particular directory. There may be easier ways to do this, or even a way to trigger a Win32 directory selection box.

Really, I'm looking for advice on how to correctly search a folder using al_findfirst, al_findnext, and al_findclose.

What's so difficult?

LennyLen
Quote:

al_findfirst("*.*", &info, 0)

Instead of 0, use FA_ALL as the last parameter.

CGamesPlay
Quote:

What's so difficult?

Well, you said that, but then posted code that appears to work (LennyLen points out a deficiency), and you didn't say that it didn't work.

Thread #590515. Printed from Allegro.cc