Commit 5c67d339 authored by hybrid's avatar hybrid

Fix LZMA uncompression. Added test case to ensure proper decoding.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3914 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 480c2847
......@@ -794,9 +794,12 @@ IReadFile* CZipReader::createAndOpenFile(u32 index)
SizeT tmpDstSize = uncompressedSize;
SizeT tmpSrcSize = decryptedSize;
unsigned int propSize = (pcData[3]<<8)+pcData[2];
int err = LzmaDecode((Byte*)pBuf, &tmpDstSize,
pcData, &tmpSrcSize,
0, 0, LZMA_FINISH_END, &status, &lzmaAlloc);
pcData+4+propSize, &tmpSrcSize,
pcData+4, propSize,
e.header.GeneralBitFlag&0x1?LZMA_FINISH_END:LZMA_FINISH_ANY, &status,
&lzmaAlloc);
uncompressedSize = tmpDstSize; // may be different to expected value
if (decrypted)
......@@ -806,8 +809,7 @@ IReadFile* CZipReader::createAndOpenFile(u32 index)
if (err != SZ_OK)
{
swprintf ( buf, 64, L"Error decompressing %s", Files[index].FullName.c_str() );
os::Printer::log( buf, ELL_ERROR);
os::Printer::log( "Error decompressing", Files[index].FullName, ELL_ERROR);
delete [] pBuf;
return 0;
}
......
......@@ -280,7 +280,7 @@ bool testEncryptedZip(IFileSystem* fs)
return true;
}
bool testSpecialZip(IFileSystem* fs)
bool testSpecialZip(IFileSystem* fs, const char* archiveName, const char* filename, const void* content)
{
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
......@@ -289,7 +289,6 @@ bool testSpecialZip(IFileSystem* fs)
return false;
}
const char* archiveName = "media/Monty.zip";
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting archive failed\n");
......@@ -312,7 +311,6 @@ bool testSpecialZip(IFileSystem* fs)
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
}
io::path filename("monty/license.txt");
if (!fs->existFile(filename))
{
logTestString("existFile failed\n");
......@@ -330,7 +328,7 @@ bool testSpecialZip(IFileSystem* fs)
char tmp[6] = {'\0'};
readFile->read(tmp, 5);
if (strcmp(tmp, "Monty"))
if (memcmp(tmp, content, 5))
{
logTestString("Read bad data from archive: %s\n", tmp);
readFile->drop();
......@@ -414,7 +412,10 @@ bool archiveReader()
logTestString("Testing encrypted zip files.\n");
ret &= testEncryptedZip(fs);
logTestString("Testing special zip files.\n");
ret &= testSpecialZip(fs);
ret &= testSpecialZip(fs, "media/Monty.zip", "monty/license.txt", "Monty");
logTestString("Testing special zip files lzma.\n");
const u8 buf[] = {0xff, 0xfe, 0x3c, 0x00, 0x3f};
ret &= testSpecialZip(fs, "media/lzmadata.zip", "tahoma10_.xml", buf);
// logTestString("Testing complex mount file.\n");
// ret &= testMountFile(fs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment