Bugfix by Vitek to allow zip files inside zip files.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1491 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2008-08-14 07:57:16 +00:00
parent 565fc47062
commit 6bdb14fd7f
1 changed files with 25 additions and 33 deletions

View File

@ -41,7 +41,6 @@ CFileSystem::CFileSystem()
} }
//! destructor //! destructor
CFileSystem::~CFileSystem() CFileSystem::~CFileSystem()
{ {
@ -58,7 +57,6 @@ CFileSystem::~CFileSystem()
} }
//! opens a file for read access //! opens a file for read access
IReadFile* CFileSystem::createAndOpenFile(const c8* filename) IReadFile* CFileSystem::createAndOpenFile(const c8* filename)
{ {
@ -86,10 +84,10 @@ IReadFile* CFileSystem::createAndOpenFile(const c8* filename)
return file; return file;
} }
file = createReadFile(filename); return createReadFile(filename);
return file;
} }
//! Creates an IReadFile interface for treating memory like a file. //! Creates an IReadFile interface for treating memory like a file.
IReadFile* CFileSystem::createMemoryReadFile(void* memory, s32 len, IReadFile* CFileSystem::createMemoryReadFile(void* memory, s32 len,
const c8* fileName, bool deleteMemoryWhenDropped) const c8* fileName, bool deleteMemoryWhenDropped)
@ -100,6 +98,7 @@ IReadFile* CFileSystem::createMemoryReadFile(void* memory, s32 len,
return new CMemoryReadFile(memory, len, fileName, deleteMemoryWhenDropped); return new CMemoryReadFile(memory, len, fileName, deleteMemoryWhenDropped);
} }
//! Opens a file for write access. //! Opens a file for write access.
IWriteFile* CFileSystem::createAndWriteFile(const c8* filename, bool append) IWriteFile* CFileSystem::createAndWriteFile(const c8* filename, bool append)
{ {
@ -109,76 +108,64 @@ IWriteFile* CFileSystem::createAndWriteFile(const c8* filename, bool append)
bool CFileSystem::addFolderFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) bool CFileSystem::addFolderFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths)
{ {
bool ret = false; CUnZipReader* zr = new CUnZipReader(this, filename, ignoreCase, ignorePaths);
CUnZipReader* zr = new CUnZipReader( this, filename, ignoreCase, ignorePaths);
if (zr) if (zr)
{
UnZipFileSystems.push_back(zr); UnZipFileSystems.push_back(zr);
ret = true;
}
#ifdef _DEBUG #ifdef _DEBUG
if ( false == ret ) else
{ {
os::Printer::log("Could not open file. UnZipfile not added", filename, ELL_ERROR); os::Printer::log("Could not open file. Folderfile not added", filename, ELL_ERROR);
} }
#endif #endif
return ret; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return (zr!=0);
} }
//! adds an zip archive to the filesystem //! adds an zip archive to the filesystem
bool CFileSystem::addZipFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) bool CFileSystem::addZipFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths)
{ {
IReadFile* file = createReadFile(filename); CZipReader* zr = 0;
IReadFile* file = createAndOpenFile(filename);
if (file) if (file)
{ {
CZipReader* zr = new CZipReader(file, ignoreCase, ignorePaths); zr = new CZipReader(file, ignoreCase, ignorePaths);
if (zr) if (zr)
ZipFileSystems.push_back(zr); ZipFileSystems.push_back(zr);
file->drop(); file->drop();
bool ret = (zr != 0);
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return ret;
} }
#ifdef _DEBUG #ifdef _DEBUG
os::Printer::log("Could not open file. Zipfile not added", filename, ELL_ERROR); else
os::Printer::log("Could not open file. Zipfile not added", filename, ELL_ERROR);
#endif #endif
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false; return (zr != 0);
} }
//! adds an pak archive to the filesystem //! adds an pak archive to the filesystem
bool CFileSystem::addPakFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths) bool CFileSystem::addPakFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths)
{ {
IReadFile* file = createReadFile(filename); CPakReader* zr = 0;
IReadFile* file = createAndOpenFile(filename);
if (file) if (file)
{ {
CPakReader* zr = new CPakReader(file, ignoreCase, ignorePaths); zr = new CPakReader(file, ignoreCase, ignorePaths);
if (zr) if (zr)
PakFileSystems.push_back(zr); PakFileSystems.push_back(zr);
file->drop(); file->drop();
bool ret = (zr != 0);
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return ret;
} }
#ifdef _DEBUG #ifdef _DEBUG
os::Printer::log("Could not open file. Pakfile not added", filename, ELL_ERROR); else
os::Printer::log("Could not open file. Pakfile not added", filename, ELL_ERROR);
#endif #endif
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false; return (zr != 0);
} }
@ -215,6 +202,7 @@ bool CFileSystem::changeWorkingDirectoryTo(const c8* newDirectory)
return success; return success;
} }
core::stringc CFileSystem::getAbsolutePath(const core::stringc& filename) const core::stringc CFileSystem::getAbsolutePath(const core::stringc& filename) const
{ {
c8 *p=0; c8 *p=0;
@ -325,6 +313,7 @@ IXMLReader* CFileSystem::createXMLReader(IReadFile* file)
return createIXMLReader(file); return createIXMLReader(file);
} }
//! Creates a XML Reader from a file. //! Creates a XML Reader from a file.
IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename) IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename)
{ {
@ -337,6 +326,7 @@ IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename)
return reader; return reader;
} }
//! Creates a XML Reader from a file. //! Creates a XML Reader from a file.
IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(IReadFile* file) IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(IReadFile* file)
{ {
@ -371,12 +361,14 @@ IFileSystem* createFileSystem()
return new CFileSystem(); return new CFileSystem();
} }
//! Creates a new empty collection of attributes, usable for serialization and more. //! Creates a new empty collection of attributes, usable for serialization and more.
IAttributes* CFileSystem::createEmptyAttributes(video::IVideoDriver* driver) IAttributes* CFileSystem::createEmptyAttributes(video::IVideoDriver* driver)
{ {
return new CAttributes(driver); return new CAttributes(driver);
} }
} // end namespace irr } // end namespace irr
} // end namespace io } // end namespace io