Game Development Community

Knowing all the files in a specified directory

by Benjamin L. Grauer · in Torque Game Builder · 06/07/2007 (8:52 pm) · 4 replies

Using torquescript, I need to know all the files that are in a specified directory. Just like getDirectoryList() do for finding folder, but with files. Is there a way to do this ?

#1
06/07/2007 (10:09 pm)
Take a look to the Reference Guide, there is it.
#2
06/07/2007 (10:20 pm)
There is only "getDirectoryList()" which do not find files, only folders.
I need to know what files are in a said folder. Maybe using "findfirstfile(%pattern)" or such but I can't figure out the %pattern thing and I'm unsure of what it's doing.
#3
06/08/2007 (2:39 am)
With
# findFirstFile(%pattern)
# findNextFile(%pattern)
# getFileCount(%pattern)

you can walk through directory and get any file you need.
Also you can build a list of the files in a directory.


%pattern:
This is full description of it

%pattern goes to _expression:

// NAME
// FindMatch::FindMatch( const char *_expression, S32 maxNumMatches )
//
// DESCRIPTION
// Class to match regular expressions (file names)
// only works with '*','?', and 'chars'
//
// ARGUMENTS
// _expression - The regular expression you intend to match (*.??abc.bmp)
// _maxMatches - The maximum number of strings you wish to match.
//

So if you put to the %pattern '*' you get first file with findFirstFile function.
#4
06/09/2007 (3:33 am)
Yay it's perfect, thanks a lot Iggor ^^