Implement irrklang::IFileFactory, as you have in mind, and have it return your own version of the file reader, which I'll call SFileReader for the sake of brevity. SFileReader needs merely accept an IReadFile from Irrlicht and store it in a buffer.
Code: Select all
class SFileReader : public irrklang::IFileReader
{
char* buf;
public:
SFileReader( IFileSystem* f, irr::path p ) {
IReadFile* r = f->createAndOpenFile(p);
store all characters in r inside of "buf"
}
// implement all irrKlang functions related to I
ik_s32 read(void *buffer, ik_u32 sizeToRead )
{
copy sizeToRead number of characters from buf to buffer
}
// etc.
};
Add your encrypted archive via irrlicht prior to creating an instance of SFileReader. You only need to pass the pass to the file in the encrypted folder for this solution to work. No need to access the files in the encrypted folder directly.
You shouldn't even need to worry about the format. Beautifully simple, I'd say.
You can see an example of this buffer storage technique by looking at how it's done in COBJMeshFileLoader.cpp
Code: Select all
c8* buf = new c8[filesize];
memset(buf, 0, filesize);
file->read((void*)buf, filesize);
const c8* const bufEnd = buf+filesize;
// Process obj information
const c8* bufPtr = buf;
// ...
while(bufPtr != bufEnd) { process information in the buffer }