Allow irrKlang to use my encrypted zip files

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
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Allow irrKlang to use my encrypted zip files

Post by ibax »

Hi,

I would like to open my encrypted zip file and assign somehow to irrKlang...

I can attach it to irrlicht filesystem:

Code: Select all

device->getFileSystem()->addFileArchive("soundfiles\\soundfiles.zip",true,false,irr::io::EFAT_ZIP,"mypassword");
And there is some IFileFactory solution to allow irrKlang to read files from this encrypted zip file, but I cannot solve it...

Can somebody show me a real example, how to continue? Unfortunately the addFileArchive does not returns a pointer, only a TRUE value, if the loading was successful. How to work with that file factory related solution? Because the proposed irrklang solution requires a pointer:

http://www.ambiera.com/irrklang/docu/in ... Overriding
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Allow irrKlang to use my encrypted zip files

Post by CuteAlien »

Ambiere has it's own forum for irrKlang: http://www.ambiera.com/forum.php?f=1
Better ask questions about that there. We are not really that familiar with irrKlang here (it was written originally by the same author, so it has some connections, but it's really another software package).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: Allow irrKlang to use my encrypted zip files

Post by chronologicaldot »

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 }
 
Post Reply