Commit 09cd4c38 authored by cutealien's avatar cutealien

bugfix: CMountPointReader::openFile no longer returns file for empty...

bugfix: CMountPointReader::openFile no longer returns file for empty filenames. Corresponding test added.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2421 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 23cfb47e
......@@ -108,7 +108,7 @@ CZipReader::CZipReader(IReadFile* file, bool ignoreCase, bool ignorePaths)
Base.replace ( '\\', '/' );
// scan local headers
while (scanLocalHeader());
while (scanLocalHeader()) ;
//while (scanLocalHeader2());
// prepare file index for binary search
......@@ -603,6 +603,9 @@ void CMountPointReader::buildDirectory ( )
//! opens a file by file name
IReadFile* CMountPointReader::openFile(const core::string<c16>& filename)
{
if ( !filename.size() )
return 0;
core::string<c16> fname ( Base );
fname += filename;
......
#include "irrlicht.h"
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace io;
bool filesystem(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert(device);
if(!device)
return false;
io::IFileSystem * fs = device->getFileSystem ();
if ( !fs )
return false;
bool result = true;
core::string<c16> workingDir = device->getFileSystem()->getWorkingDirectory();
core::string<c16> empty;
if ( fs->existFile(empty) )
{
logTestString("Empty filename should not exist.\n");
result = false;
}
stringc newWd = workingDir + "/media";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd);
assert(changed);
if ( fs->existFile(empty) )
{
logTestString("Empty filename should not exist even in another workingdirectory.\n");
result = false;
}
// The working directory must be restored for the other tests to work.
changed = device->getFileSystem()->changeWorkingDirectoryTo(workingDir.c_str());
assert(changed);
// adding a folder archive which just should not really change anything
device->getFileSystem()->addFolderFileArchive( "./" );
if ( fs->existFile(empty) )
{
logTestString("Empty filename should not exist in folder file archive.\n");
result = false;
}
// remove it again to not affect other tests
device->getFileSystem()->unregisterFileArchive( device->getFileSystem()->getFileArchiveCount() );
return result;
}
......@@ -57,6 +57,7 @@ int main(int argumentCount, char * arguments[])
// process.
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
TEST(filesystem);
TEST(zipReader);
TEST(exports);
TEST(sceneCollisionManager);
......
Test suite pass at GMT Thu Jun 11 22:44:22 2009
Test suite pass at GMT Mon Jun 15 15:44:00 2009
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