Locking the file system directory

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
PumpkinPieman
Posts: 13
Joined: Fri Apr 20, 2007 4:35 pm

Locking the file system directory

Post by PumpkinPieman »

Before I start my project I've been trying to set a structure up for the application where the file system will only allow access to loading files from "data/<modname>.zip" and "/data/<modname>". However doing a few routine tests I've found that if I set the working directory to "data" and load a texture in the parent directory (../texture.jpg) it seems to go through fine.

Is there a way to lock the user out of accessing any file but those folders that have been mapped?

(The use I have for this is for modding and giving the scripters little to no access to data which is not theirs)
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Just write some code that is called before the file system is accessed for loading a file. That code would check for a legal path and refuse to load a file that was not acceptable.

Code: Select all

IReadFile* IFileSystem_safeOpenFile(const char* fileName)
{
  // decide if fileName is a legal filename to access...


  // if not, return a null pointer
  if (!isAcceptableFileName)
    return 0;

  // otherwise access the file
  return FileSystem->openFile(fileName);
}
Don't ever give the mod a pointer to the file system for opening files, just give them a pointer to a function similar to above for opening them.

Your other choice would be to modify the source of the file system, patch it, and rebuild the library.

Travis
PumpkinPieman
Posts: 13
Joined: Fri Apr 20, 2007 4:35 pm

Post by PumpkinPieman »

Yeah. I was just planning on using boost regex and stripping any occurance of (.[^.]*[^/]*) (or something to that effect).

I was just kind of hoping irrlicht could simplify it for me.
Post Reply