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)
Locking the file system directory
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.
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
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);
}
Your other choice would be to modify the source of the file system, patch it, and rebuild the library.
Travis
-
- Posts: 13
- Joined: Fri Apr 20, 2007 4:35 pm