I have a routine in a game I'm writing which loads and executes a script file. It uses the Irrlicht filesystem to support transparently loading the script from an archive or a directory.
The code works fine, except when the code is called a second (or further) time with the same arguments: the call to createAndOpenFile returns a null pointer. To solve this problem I am considering writing a script caching system, which will be beneficial anyway, but I am interested to know if I am misusing the Irrlicht filesystem or if there is another cause for this unusual problem.
I should add that the file is a physical file, not in an archive. I was therefore worried that the first opening of the file isn't getting closed, but there doesn't appear to be any method other than drop which would close the file.
Well this is a bit embarassing... there was indeed a call to change the working directory in a superclass method /after/ it calls the script, so it works the first time and fails on consecutive runs. Thank you for that idea bitplane, it has solved my problem