Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » file_select_ex

This thread is locked; no one can reply to it. rss feed Print
file_select_ex
ngiacomelli
Member #5,114
October 2004

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
Member #2,559
July 2002
avatar

You forgot to ask a question.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

ngiacomelli
Member #5,114
October 2004

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
Member #5,313
December 2004
avatar

Quote:

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

Instead of 0, use FA_ALL as the last parameter.

CGamesPlay
Member #2,559
July 2002
avatar

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.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Go to: