Commit d21c24b1 authored by hybrid's avatar hybrid

Fix directory recognition in ZIP reader. Added tests for findFile with and without directories.

Fix warning message in CAnimatedMeshSceneNode
Change C-cast to reinterpret in CIrrDeviceLinux

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3548 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 316183d8
...@@ -595,7 +595,7 @@ IBoneSceneNode* CAnimatedMeshSceneNode::getJointNode(const c8* jointName) ...@@ -595,7 +595,7 @@ IBoneSceneNode* CAnimatedMeshSceneNode::getJointNode(const c8* jointName)
if (number == -1) if (number == -1)
{ {
os::Printer::log("Joint with specified name not found in skinned mesh.", jointName, ELL_DEBUG); os::Printer::log("Joint with specified name not found in skinned mesh", jointName, ELL_DEBUG);
return 0; return 0;
} }
......
...@@ -1024,7 +1024,7 @@ bool CIrrDeviceLinux::run() ...@@ -1024,7 +1024,7 @@ bool CIrrDeviceLinux::run()
irrevent.EventType = irr::EET_KEY_INPUT_EVENT; irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
irrevent.KeyInput.PressedDown = (event.type == KeyPress); irrevent.KeyInput.PressedDown = (event.type == KeyPress);
// mbtowc(&irrevent.KeyInput.Char, buf, sizeof(buf)); // mbtowc(&irrevent.KeyInput.Char, buf, sizeof(buf));
irrevent.KeyInput.Char = ((wchar_t*)(buf))[0]; irrevent.KeyInput.Char = (reinterpret_cast<wchar_t*>(buf))[0];
irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0; irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0;
irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0; irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0;
postEventFromUser(irrevent); postEventFromUser(irrevent);
......
...@@ -428,7 +428,7 @@ bool CZipReader::scanZipHeader(bool ignoreGPBits) ...@@ -428,7 +428,7 @@ bool CZipReader::scanZipHeader(bool ignoreGPBits)
//os::Debuginfo::print("added file from archive", ZipFileName.c_str()); //os::Debuginfo::print("added file from archive", ZipFileName.c_str());
#endif #endif
addItem(ZipFileName, entry.Offset, entry.header.DataDescriptor.UncompressedSize, false, FileInfo.size()); addItem(ZipFileName, entry.Offset, entry.header.DataDescriptor.UncompressedSize, ZipFileName.lastChar()=='/', FileInfo.size());
FileInfo.push_back(entry); FileInfo.push_back(entry);
return true; return true;
......
...@@ -187,14 +187,40 @@ bool testEncryptedZip(IFileSystem* fs) ...@@ -187,14 +187,40 @@ bool testEncryptedZip(IFileSystem* fs)
// log what we got // log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1); io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
io::path filename("doc");
const io::IFileList* fileList = archive->getFileList(); const io::IFileList* fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f) for ( u32 f=0; f < fileList->getFileCount(); ++f)
{ {
logTestString("File name: %s\n", fileList->getFileName(f).c_str()); logTestString("%s name: %s\n", fileList->isDirectory(f)?"Directory":"File", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str()); logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
} }
if (fileList->findFile(filename) != -1)
io::path filename("doc/readme.txt"); {
logTestString("findFile wrongly succeeded on directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (fileList->findFile(filename, true)==-1)
{
logTestString("findFile failed on directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
filename="doc/readme.txt";
if (fileList->findFile(filename)==-1)
{
logTestString("findFile failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (fileList->findFile(filename, true) != -1)
{
logTestString("findFile wrongly succeeded on non-directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (!fs->existFile(filename)) if (!fs->existFile(filename))
{ {
logTestString("existFile failed\n"); logTestString("existFile failed\n");
...@@ -202,6 +228,15 @@ bool testEncryptedZip(IFileSystem* fs) ...@@ -202,6 +228,15 @@ bool testEncryptedZip(IFileSystem* fs)
return false; return false;
} }
filename="doc";
if (fs->existFile(filename))
{
logTestString("existFile succeeded wrongly on directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
filename="doc/readme.txt";
IReadFile* readFile = fs->createAndOpenFile(filename); IReadFile* readFile = fs->createAndOpenFile(filename);
if ( readFile ) if ( readFile )
{ {
...@@ -273,7 +308,7 @@ bool testSpecialZip(IFileSystem* fs) ...@@ -273,7 +308,7 @@ bool testSpecialZip(IFileSystem* fs)
const io::IFileList* fileList = archive->getFileList(); const io::IFileList* fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f) for ( u32 f=0; f < fileList->getFileCount(); ++f)
{ {
logTestString("File name: %s\n", fileList->getFileName(f).c_str()); logTestString("%s name: %s\n", fileList->isDirectory(f)?"Directory":"File", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str()); logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
} }
......
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