Better file system design?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
bull
Posts: 36
Joined: Wed Sep 12, 2007 8:49 am
Location: s1Ng4p0R3

Better file system design?

Post by bull »

Recently, there are a lot of questions about encryption. The current filesystem is not flexible enough and is incapable of such things without modification.
I want to propose a new design for the file system, which IMO is more flexible:

pseudo-code:

class IFileSystem:
{
public:
void addSubSystem(IFileSubSystem* fss)
createAndWriteFile()
createAndOpenFile()
//other methods like addZipArchive can be added here
...
}

class IFileSubSystem: //or ISubFileSystem, I dont know which is the right way to write it :oops:
{
IReadFile* createAndOpenFile()// return null if there's no such file in this subsystem
IWriteFile* createAndWriteFile()// return null if the file cannot be written or this subsystem is read-only
}

implementation of IFileSystem
class CFileSystem:
{
void addSubSystem(IFileSubSystem* fss)
{
subsystems.push_front(fss);//so that new subsystems overides old subsystems
}
createAndWriteFile()
{
//iterate through the list of subsystems.
//call createAndWriteFile on them
//return the first non-null result
}
createAndOpenFile()
{
//iterate through the list of subsystems.
//call createAndOpenFile on them
//return the first non-null result
}

private:
core::list<fss*> subsystems;
}

With this design:

-Zip archive, pak archive , folder archive, memory file can then be implemented as subsystems. We will have some built-in subsystems such as : CRealFileSystem(which use normal file access), CZipFileSystem, CPakFileSystem, CFolderSystem, CMemoryFileSystem ...
-changeWorkingDirectory can be done by changing the directory the current CFolderSystem
-Users have full control of input/output by writing their own subsystems to overrides the built-in ones. They can use whatever encryption
-Minimal rewrite: you only need to cut the existing code of CFileSystem and then paste it to different subsystems.

I know file system is of low priority compare to other things but a flexible virtual filesystem is important for game dev, which I think most irrlicht users are doing. It helps a lot in creating moddable games, protecting assets ....
My name is bull, for we are many ...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Go search for the already existing fileSystem redesign thread. Would be better to add to that one instead of developing completely different design. And try to use the code tags to make your code more readable (it's even better to avoid code at all in design phases...)
Post Reply