How to search for files
Kikaru

How should I go about searching for different files in a directory, such as all files of one extension, without user input?

CGamesPlay
Kikaru

Thanks. Just one last question: with for_each_file_ex, is it possible to limit it to one directory, such as the same one as the .exe?

CGamesPlay

Yes. It doesn't recurse into subdirectories in the first place.

replace_filename, get_executable_name

Kikaru

Ok. Thanks. So, to find .sav files in a folder named SAVES in the directory as my game, I would do this:

for_each_file_ex("SAVES//*.sav", ..., my_callback, ...);

?

LennyLen
Quote:

for_each_file_ex("SAVES//*.sav", ..., my_callback, ...);

Yes, except that you would specify the directory as "SAVES/*.sav" (or under DOS/Windows "SAVES\*.sav").

Kikaru

Oh. Yeah, I use windows and forgot which way the slashes went. ;D

Thanks for the help! :)

BAF

You might as well use /. It's more readable IMO because it doesn't require escaping, and it is cross-platform (unlike \).

Kikaru

'\\' is for windows. I don't think '/' works on windows though. :P

LennyLen
Quote:

I don't think '/' works on windows though

Yes it does.

Thread #590511. Printed from Allegro.cc