My project requires to use Irrlicht read Java zipped or jarred files. I tried to add them to the file system cache by using
Code: Select all
device->getFileSystem()->addZipFileArchive(...)
Code: Select all
device->getFileSystem()->createAndOpenFile(...)
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
IrrlichtDevice *device =
createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("./derbyclient.jar", true, false);
irr::io::IReadFile* indexFile = device->getFileSystem()->createAndOpenFile("META-INF/eclipse.inf");
char* indexXml = new char[indexFile->getSize() + 1];
irr::s32 fileSize = indexFile->read(indexXml, indexFile->getSize());
indexXml[fileSize] = '\0';
std::cout << indexXml << std::endl;
delete [] indexXml;
device->drop();
indexFile->drop();
return 0;
}
In the above code, indexFile is always returned 0.
The root cause of this problem is that in "CZipReader.cpp", the "entry.header.GeneralBitFlag" for a Java zipped or jarred file is 8 so Irrlicht tries to get CRC32, CompressedSize and UncompressedSize from the Zip or the Jar, but they are not set by Java. But when I read a WinZip created file, "entry.header.GeneralBitFlag" is 0.
But WinZip can open Java zipped or jarred files without any problem.
Does anybody know a solution about this problem?
Thanks