FindFirstFile / findNextFile - results cached?
by Keith Johnston · in Torque Game Engine · 03/21/2004 (6:07 pm) · 8 replies
It seems as though the results from findFirstFile / findNextFile are cached - if I create a new file in a directory it does not get picked up until the next time I restart the engine.
Anyone have a workaround they could share for this?
Anyone have a workaround they could share for this?
#2
03/21/2004 (7:13 pm)
That worked! Thank you!
#3
03/21/2004 (8:53 pm)
That's an awesome hack, Labbie. I'll have to remember that...
#4
thanks!
08/16/2006 (6:55 pm)
It works but setModPaths(getModPaths()) causes an awefully slow delay probablay due to the amount of file it has to build up in the modPath. If I just want to walk through all the files in a directory, is there something else I can use besides findFirstFile/findNextFile?thanks!
#5
Seems to me getmodpaths is just doing an automated process.. if you know your mod paths dont change (much) then I'd say go for it and set em manually in the function call.
Cheers
08/17/2006 (9:43 am)
Justa thought but couldnt you actually insert the paths in the setmodpath(xxxx,xxxx,xxxx)?Seems to me getmodpaths is just doing an automated process.. if you know your mod paths dont change (much) then I'd say go for it and set em manually in the function call.
Cheers
#6
08/17/2006 (11:07 am)
But it's setmodpaths that's actually causing the performance delay, not getmodpaths(). so even if I call setmodpaths(xxx,xxx,xxx) in the function call every time, it's gonna be slow
#7
Of course, each additional mod path in setModPaths() will increase this search time. (Common, Creator, the game base, etc.). But I don't believe that it was intended for the Resource List be refreshed on a constant basis or during time-critical portions of the game. It something that's supposed to be done once at the start of the game (or I suppose possibly during level loading) and then it's left alone.
I don't think there is any functionality (currently) to handle searching for files/folders other than findFirstFile() and findNextFile(). At least, nothing that is exposed to script. There are several functions that may be helpful if exposed to script, however. Check out the Resource Manager code (resManager.h/.cc) and you may find what you're looking for...
08/17/2006 (12:22 pm)
All file processing is handled through the Resource Manager. setModPaths() is used to inform the Resource Manager about all resources (i.e. files) in the game folder structure -- it goes out and searches for all files that match the known file types (registered with the Resource Manager in main.cc, line 75-ish) and adds them to the Resource List. Then findFirstFile(), findNextFile(), and the other file-related functions check the Resource List.Of course, each additional mod path in setModPaths() will increase this search time. (Common, Creator, the game base, etc.). But I don't believe that it was intended for the Resource List be refreshed on a constant basis or during time-critical portions of the game. It something that's supposed to be done once at the start of the game (or I suppose possibly during level loading) and then it's left alone.
I don't think there is any functionality (currently) to handle searching for files/folders other than findFirstFile() and findNextFile(). At least, nothing that is exposed to script. There are several functions that may be helpful if exposed to script, however. Check out the Resource Manager code (resManager.h/.cc) and you may find what you're looking for...
#8
08/17/2006 (5:27 pm)
Thanks for the advise. I'll look more into resManager.
Torque Owner Harold "LabRat" Brown