getting extracted filepaths from zip file

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
NioZero
Posts: 7
Joined: Tue Nov 17, 2009 1:04 am
Location: Concepción, Chile
Contact:

getting extracted filepaths from zip file

Post by NioZero »

hi...


i have used irrlicht file system to store all my models,textures and data into a zip file.. like this

Code: Select all

device->getFileSystem()->addFileArchive("data.zip",true,true,irr::io::EFAT_ZIP);

when i want to create nodes using the models from this zip, i do it this way

Code: Select all

irr::video::ITexture *texture = driver->getTexture("texture.png");
irr::scene::IAnimatedMesh *mesh = smgr->getMesh("model.obj");
and it works perfectly


But suppose that the contents of the zip are these files ...

Code: Select all

texture.png
model.obj
song.mp3
other.file
and i want to load the 'song.mp3' file into another library, but that library doesn't support zip file and need a "full path" to load a song.. and because this file is contained within a zip, I suppose i need to 'extract' that file first before to get the real path. (this might apply to any file)


in other words, i need something like this...

Code: Select all

irr::io::IFileSystem *file = device->getFileSystem();
irr::io::path ExtractedPath = file->extractFileAndGetPath("song.mp3"); // or something like file->getExtractedPath("song.mp3");
mylibrary->loadSong( ExtractedPath );
Is there any way to do this? in the IFileSystem reference does not show anything related...
Image
Image
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

you can create the file in memory and pass it to other libraries

Code: Select all

  irr::io::IReadFile *readFile = filesystem->createAndOpenFile(filename);

  void* buffer = malloc(readFile->getSize());
  readFile->read(buffer, readFile->getSize());

  // create memory file using buffer and readFile->getSize()
  // with your lib here

  free(buffer);

  readFile->drop();
Never take advice from someone who likes to give advice, so take my advice and don't take it.
NioZero
Posts: 7
Joined: Tue Nov 17, 2009 1:04 am
Location: Concepción, Chile
Contact:

Post by NioZero »

Bate wrote:you can create the file in memory and pass it to other libraries

Code: Select all

  irr::io::IReadFile *readFile = filesystem->createAndOpenFile(filename);

  void* buffer = malloc(readFile->getSize());
  readFile->read(buffer, readFile->getSize());

  // create memory file using buffer and readFile->getSize()
  // with your lib here

  free(buffer);

  readFile->drop();
i am doing a little testing with audiere for now, but I would like to work for any library...

Code: Select all

irr::io::IReadFile *File = file->createAndOpenFile("song.mp3");

void* buffer = malloc( File->getSize() );
File->read( buffer , File->getSize() );
audiere::OutputStream* stream = audiere::OpenSound( audiodevice , buffer );
free(buffer);
File->drop();
but that doesn't work... even making reinterpret_cast or something else.. ( File->getFilename() only returns the file name, not the extracted path )



likewise thanks for the reply




offtopic: would be nice if the forum had installed bbgeshi. bbcodes look much better
Image
Image
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

Code: Select all

  irr::io::IReadFile *readFile = filesystem->createAndOpenFile(filename);

  void* buffer = malloc(readFile->getSize());

  readFile->read(buffer, readFile->getSize());

  // you need to create a mem file first
  FilePtr memFile = CreateMemoryFile(buffer, readFile->getSize());

  free(buffer);

  readFile->drop();

  OutputStreamPtr out = OpenSound(deviceAudio, memFile, stream, format);
Never take advice from someone who likes to give advice, so take my advice and don't take it.
NioZero
Posts: 7
Joined: Tue Nov 17, 2009 1:04 am
Location: Concepción, Chile
Contact:

Post by NioZero »

i never realized... (I don't work much with audiere), but that's works.. although the reading is very slow, especially if the files are very large ..

But it would do for a while ... thanks ..
Image
Image
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

Irrklang have a similar file managment and you can change loading method by inheriting the IFileFactory. This class is nearly the same as IFile from Irrlicht, same methods, same properties, so you just have to make the same things and you'll be able to use Irrlicht File system with Irrklang, that is to say use archive files. However it's not thread same when streaming large files...
Post Reply