Remove npk and pak support

This commit is contained in:
Vincent Lejeune 2015-01-16 19:02:03 +01:00
parent b3195e378d
commit 184b52966e
7 changed files with 1 additions and 758 deletions

View File

@ -67,7 +67,6 @@ source/Irrlicht/CGUIMessageBox.cpp
source/Irrlicht/CParticleGravityAffector.cpp
source/Irrlicht/CGUISkin.cpp
source/Irrlicht/CBoneSceneNode.cpp
source/Irrlicht/CNPKReader.cpp
source/Irrlicht/COpenGLSLMaterialRenderer.cpp
source/Irrlicht/CParticleRotationAffector.cpp
source/Irrlicht/CTriangleBBSelector.cpp
@ -109,7 +108,6 @@ source/Irrlicht/CEmptySceneNode.cpp
source/Irrlicht/CParticleBoxEmitter.cpp
source/Irrlicht/CParticleSystemSceneNode.cpp
source/Irrlicht/CIrrDeviceConsole.cpp
source/Irrlicht/CPakReader.cpp
source/Irrlicht/CImage.cpp
source/Irrlicht/CTarReader.cpp
source/Irrlicht/CGUIButton.cpp
@ -217,14 +215,6 @@ source/Irrlicht/COpenGLDriver.h
source/Irrlicht/CGUIComboBox.h
source/Irrlicht/CSceneCollisionManager.h
source/Irrlicht/ISceneNodeAnimatorFinishing.h
source/Irrlicht/aesGladman/pwd2key.h
source/Irrlicht/aesGladman/sha2.h
source/Irrlicht/aesGladman/hmac.h
source/Irrlicht/aesGladman/fileenc.h
source/Irrlicht/aesGladman/aes.h
source/Irrlicht/aesGladman/sha1.h
source/Irrlicht/aesGladman/prng.h
source/Irrlicht/aesGladman/aesopt.h
source/Irrlicht/CGUITabControl.h
source/Irrlicht/CSphereSceneNode.h
source/Irrlicht/CIrrDeviceStub.h
@ -270,7 +260,6 @@ source/Irrlicht/CGUIImageList.h
source/Irrlicht/CFileSystem.h
source/Irrlicht/CSceneNodeAnimatorRotation.h
source/Irrlicht/CGUISkin.h
source/Irrlicht/CNPKReader.h
source/Irrlicht/S4DVertex.h
source/Irrlicht/CGUIMenu.h
source/Irrlicht/CBlit.h
@ -301,7 +290,6 @@ source/Irrlicht/CFPSCounter.h
source/Irrlicht/CGUITreeView.h
source/Irrlicht/CGUIContextMenu.h
source/Irrlicht/CFileList.h
source/Irrlicht/CPakReader.h
source/Irrlicht/CLimitReadFile.h
source/Irrlicht/CGUISpinBox.h
source/Irrlicht/CGUIButton.h

View File

@ -324,22 +324,13 @@ defined. */
#ifdef NO_IRR_USE_NON_SYSTEM_ZLIB_
#undef _IRR_USE_NON_SYSTEM_ZLIB_
#endif
#endif
//! Define __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ if you want to mount folders as archives
#define __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#ifdef NO__IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#undef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#endif
//! Define __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ if you want to open ID software PAK archives
//#define __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
#ifdef NO__IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
#undef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
#endif
//! Define __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_ if you want to open Nebula Device NPK archives
//#define __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
#ifdef NO__IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
#undef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
#endif
//! Define __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ if you want to open TAR archives
#define __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
#ifdef NO__IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_

View File

@ -9,8 +9,6 @@
#include "IWriteFile.h"
#include "CZipReader.h"
#include "CMountPointReader.h"
#include "CPakReader.h"
#include "CNPKReader.h"
#include "CTarReader.h"
#include "CWADReader.h"
#include "CFileList.h"
@ -58,14 +56,6 @@ CFileSystem::CFileSystem()
//! reset current working directory
getWorkingDirectory();
#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderPAK(this));
#endif
#ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderNPK(this));
#endif
#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderTAR(this));
#endif

View File

@ -1,277 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// Copyright (C) 2009-2012 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Based on the NPK reader from Irrlicht
#include "CNPKReader.h"
#ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
#include "os.h"
#include "coreutil.h"
#ifdef _DEBUG
#define IRR_DEBUG_NPK_READER
#endif
namespace irr
{
namespace io
{
namespace
{
bool isHeaderValid(const SNPKHeader& header)
{
const c8* const tag = header.Tag;
return tag[0] == '0' &&
tag[1] == 'K' &&
tag[2] == 'P' &&
tag[3] == 'N';
}
} // end namespace
//! Constructor
CArchiveLoaderNPK::CArchiveLoaderNPK( io::IFileSystem* fs)
: FileSystem(fs)
{
#ifdef _DEBUG
setDebugName("CArchiveLoaderNPK");
#endif
}
//! returns true if the file maybe is able to be loaded by this class
bool CArchiveLoaderNPK::isALoadableFileFormat(const io::path& filename) const
{
return core::hasFileExtension(filename, "npk");
}
//! Check to see if the loader can create archives of this type.
bool CArchiveLoaderNPK::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const
{
return fileType == EFAT_NPK;
}
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
IFileArchive* CArchiveLoaderNPK::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
io::IReadFile* file = FileSystem->createAndOpenFile(filename);
if (file)
{
archive = createArchive(file, ignoreCase, ignorePaths);
file->drop ();
}
return archive;
}
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
IFileArchive* CArchiveLoaderNPK::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
if ( file )
{
file->seek ( 0 );
archive = new CNPKReader(file, ignoreCase, ignorePaths);
}
return archive;
}
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
bool CArchiveLoaderNPK::isALoadableFileFormat(io::IReadFile* file) const
{
SNPKHeader header;
file->read(&header, sizeof(header));
return isHeaderValid(header);
}
/*!
NPK Reader
*/
CNPKReader::CNPKReader(IReadFile* file, bool ignoreCase, bool ignorePaths)
: CFileList((file ? file->getFileName() : io::path("")), ignoreCase, ignorePaths), File(file)
{
#ifdef _DEBUG
setDebugName("CNPKReader");
#endif
if (File)
{
File->grab();
if (scanLocalHeader())
sort();
else
os::Printer::log("Failed to load NPK archive.");
}
}
CNPKReader::~CNPKReader()
{
if (File)
File->drop();
}
const IFileList* CNPKReader::getFileList() const
{
return this;
}
bool CNPKReader::scanLocalHeader()
{
SNPKHeader header;
// Read and validate the header
File->read(&header, sizeof(header));
if (!isHeaderValid(header))
return false;
// Seek to the table of contents
#ifdef __BIG_ENDIAN__
header.Offset = os::Byteswap::byteswap(header.Offset);
header.Length = os::Byteswap::byteswap(header.Length);
#endif
header.Offset += 8;
core::stringc dirName;
bool inTOC=true;
// Loop through each entry in the table of contents
while (inTOC && (File->getPos() < File->getSize()))
{
// read an entry
char tag[4]={0};
SNPKFileEntry entry;
File->read(tag, 4);
const int numTag = MAKE_IRR_ID(tag[3],tag[2],tag[1],tag[0]);
int size;
bool isDir=true;
switch (numTag)
{
case MAKE_IRR_ID('D','I','R','_'):
{
File->read(&size, 4);
readString(entry.Name);
entry.Length=0;
entry.Offset=0;
#ifdef IRR_DEBUG_NPK_READER
os::Printer::log("Dir", entry.Name);
#endif
}
break;
case MAKE_IRR_ID('F','I','L','E'):
{
File->read(&size, 4);
File->read(&entry.Offset, 4);
File->read(&entry.Length, 4);
readString(entry.Name);
isDir=false;
#ifdef IRR_DEBUG_NPK_READER
os::Printer::log("File", entry.Name);
#endif
#ifdef __BIG_ENDIAN__
entry.Offset = os::Byteswap::byteswap(entry.Offset);
entry.Length = os::Byteswap::byteswap(entry.Length);
#endif
}
break;
case MAKE_IRR_ID('D','E','N','D'):
{
File->read(&size, 4);
entry.Name="";
entry.Length=0;
entry.Offset=0;
const s32 pos = dirName.findLast('/', dirName.size()-2);
if (pos==-1)
dirName="";
else
dirName=dirName.subString(0, pos);
#ifdef IRR_DEBUG_NPK_READER
os::Printer::log("Dirend", dirName);
#endif
}
break;
default:
inTOC=false;
}
// skip root dir
if (isDir)
{
if (!entry.Name.size() || (entry.Name==".") || (entry.Name=="<noname>"))
continue;
dirName += entry.Name;
dirName += "/";
}
#ifdef IRR_DEBUG_NPK_READER
os::Printer::log("Name", entry.Name);
#endif
addItem((isDir?dirName:dirName+entry.Name), entry.Offset+header.Offset, entry.Length, isDir);
}
return true;
}
//! opens a file by file name
IReadFile* CNPKReader::createAndOpenFile(const io::path& filename)
{
s32 index = findFile(filename, false);
if (index != -1)
return createAndOpenFile(index);
return 0;
}
//! opens a file by index
IReadFile* CNPKReader::createAndOpenFile(u32 index)
{
if (index >= Files.size() )
return 0;
const SFileListEntry &entry = Files[index];
return createLimitReadFile( entry.FullName, File, entry.Offset, entry.Size );
}
void CNPKReader::readString(core::stringc& name)
{
short stringSize;
char buf[256];
File->read(&stringSize, 2);
#ifdef __BIG_ENDIAN__
stringSize = os::Byteswap::byteswap(stringSize);
#endif
name.reserve(stringSize);
while(stringSize)
{
const short next = core::min_(stringSize, (short)255);
File->read(buf,next);
buf[next]=0;
name.append(buf);
stringSize -= next;
}
}
} // end namespace io
} // end namespace irr
#endif // __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_

View File

@ -1,128 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// Copyright (C) 2009-2012 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_NPK_READER_H_INCLUDED__
#define __C_NPK_READER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
#include "IReferenceCounted.h"
#include "IReadFile.h"
#include "irrArray.h"
#include "irrString.h"
#include "IFileSystem.h"
#include "CFileList.h"
namespace irr
{
namespace io
{
namespace
{
//! File header containing location and size of the table of contents
struct SNPKHeader
{
// Don't change the order of these fields! They must match the order stored on disk.
c8 Tag[4];
u32 Length;
u32 Offset;
};
//! An entry in the NPK file's table of contents.
struct SNPKFileEntry
{
core::stringc Name;
u32 Offset;
u32 Length;
};
} // end namespace
//! Archiveloader capable of loading Nebula Device 2 NPK Archives
class CArchiveLoaderNPK : public IArchiveLoader
{
public:
//! Constructor
CArchiveLoaderNPK(io::IFileSystem* fs);
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".zip")
virtual bool isALoadableFileFormat(const io::path& filename) const;
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
//! Check to see if the loader can create archives of this type.
/** Check based on the archive type.
\param fileType The archive type to check.
\return True if the archile loader supports this type, false if not */
virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const;
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const;
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const;
//! Returns the type of archive created by this loader
virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_NPK; }
private:
io::IFileSystem* FileSystem;
};
//! reads from NPK
class CNPKReader : public virtual IFileArchive, virtual CFileList
{
public:
CNPKReader(IReadFile* file, bool ignoreCase, bool ignorePaths);
virtual ~CNPKReader();
// file archive methods
//! return the id of the file Archive
virtual const io::path& getArchiveName() const
{
return File->getFileName();
}
//! opens a file by file name
virtual IReadFile* createAndOpenFile(const io::path& filename);
//! opens a file by index
virtual IReadFile* createAndOpenFile(u32 index);
//! returns the list of files
virtual const IFileList* getFileList() const;
//! get the class Type
virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_NPK; }
private:
//! scans for a local header, returns false if the header is invalid
bool scanLocalHeader();
void readString(core::stringc& name);
IReadFile* File;
};
} // end namespace io
} // end namespace irr
#endif // __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
#endif // __C_NPK_READER_H_INCLUDED__

View File

@ -1,196 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Code contributed by skreamz
#include "CPakReader.h"
#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
#include "os.h"
#include "coreutil.h"
namespace irr
{
namespace io
{
namespace
{
inline bool isHeaderValid(const SPAKFileHeader& header)
{
const c8* tag = header.tag;
return tag[0] == 'P' &&
tag[1] == 'A' &&
tag[2] == 'C' &&
tag[3] == 'K';
}
} // end namespace
//! Constructor
CArchiveLoaderPAK::CArchiveLoaderPAK( io::IFileSystem* fs)
: FileSystem(fs)
{
#ifdef _DEBUG
setDebugName("CArchiveLoaderPAK");
#endif
}
//! returns true if the file maybe is able to be loaded by this class
bool CArchiveLoaderPAK::isALoadableFileFormat(const io::path& filename) const
{
return core::hasFileExtension(filename, "pak");
}
//! Check to see if the loader can create archives of this type.
bool CArchiveLoaderPAK::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const
{
return fileType == EFAT_PAK;
}
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
IFileArchive* CArchiveLoaderPAK::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
io::IReadFile* file = FileSystem->createAndOpenFile(filename);
if (file)
{
archive = createArchive(file, ignoreCase, ignorePaths);
file->drop ();
}
return archive;
}
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
IFileArchive* CArchiveLoaderPAK::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
if ( file )
{
file->seek ( 0 );
archive = new CPakReader(file, ignoreCase, ignorePaths);
}
return archive;
}
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
bool CArchiveLoaderPAK::isALoadableFileFormat(io::IReadFile* file) const
{
SPAKFileHeader header;
file->read(&header, sizeof(header));
return isHeaderValid(header);
}
/*!
PAK Reader
*/
CPakReader::CPakReader(IReadFile* file, bool ignoreCase, bool ignorePaths)
: CFileList((file ? file->getFileName() : io::path("")), ignoreCase, ignorePaths), File(file)
{
#ifdef _DEBUG
setDebugName("CPakReader");
#endif
if (File)
{
File->grab();
scanLocalHeader();
sort();
}
}
CPakReader::~CPakReader()
{
if (File)
File->drop();
}
const IFileList* CPakReader::getFileList() const
{
return this;
}
bool CPakReader::scanLocalHeader()
{
SPAKFileHeader header;
// Read and validate the header
File->read(&header, sizeof(header));
if (!isHeaderValid(header))
return false;
// Seek to the table of contents
#ifdef __BIG_ENDIAN__
header.offset = os::Byteswap::byteswap(header.offset);
header.length = os::Byteswap::byteswap(header.length);
#endif
File->seek(header.offset);
const int numberOfFiles = header.length / sizeof(SPAKFileEntry);
// Loop through each entry in the table of contents
for(int i = 0; i < numberOfFiles; i++)
{
// read an entry
SPAKFileEntry entry;
File->read(&entry, sizeof(entry));
#ifdef _DEBUG
os::Printer::log(entry.name);
#endif
#ifdef __BIG_ENDIAN__
entry.offset = os::Byteswap::byteswap(entry.offset);
entry.length = os::Byteswap::byteswap(entry.length);
#endif
addItem(io::path(entry.name), entry.offset, entry.length, false );
}
return true;
}
//! opens a file by file name
IReadFile* CPakReader::createAndOpenFile(const io::path& filename)
{
s32 index = findFile(filename, false);
if (index != -1)
return createAndOpenFile(index);
return 0;
}
//! opens a file by index
IReadFile* CPakReader::createAndOpenFile(u32 index)
{
if (index >= Files.size() )
return 0;
const SFileListEntry &entry = Files[index];
return createLimitReadFile( entry.FullName, File, entry.Offset, entry.Size );
}
} // end namespace io
} // end namespace irr
#endif // __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_

View File

@ -1,125 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_PAK_READER_H_INCLUDED__
#define __C_PAK_READER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
#include "IReferenceCounted.h"
#include "IReadFile.h"
#include "irrArray.h"
#include "irrString.h"
#include "IFileSystem.h"
#include "CFileList.h"
namespace irr
{
namespace io
{
//! File header containing location and size of the table of contents
struct SPAKFileHeader
{
// Don't change the order of these fields! They must match the order stored on disk.
c8 tag[4];
u32 offset;
u32 length;
};
//! An entry in the PAK file's table of contents.
struct SPAKFileEntry
{
// Don't change the order of these fields! They must match the order stored on disk.
c8 name[56];
u32 offset;
u32 length;
};
//! Archiveloader capable of loading PAK Archives
class CArchiveLoaderPAK : public IArchiveLoader
{
public:
//! Constructor
CArchiveLoaderPAK(io::IFileSystem* fs);
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".zip")
virtual bool isALoadableFileFormat(const io::path& filename) const;
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
//! Check to see if the loader can create archives of this type.
/** Check based on the archive type.
\param fileType The archive type to check.
\return True if the archile loader supports this type, false if not */
virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const;
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const;
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const;
//! Returns the type of archive created by this loader
virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_PAK; }
private:
io::IFileSystem* FileSystem;
};
//! reads from pak
class CPakReader : public virtual IFileArchive, virtual CFileList
{
public:
CPakReader(IReadFile* file, bool ignoreCase, bool ignorePaths);
virtual ~CPakReader();
// file archive methods
//! return the id of the file Archive
virtual const io::path& getArchiveName() const
{
return File->getFileName();
}
//! opens a file by file name
virtual IReadFile* createAndOpenFile(const io::path& filename);
//! opens a file by index
virtual IReadFile* createAndOpenFile(u32 index);
//! returns the list of files
virtual const IFileList* getFileList() const;
//! get the class Type
virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_PAK; }
private:
//! scans for a local header, returns false if the header is invalid
bool scanLocalHeader();
IReadFile* File;
};
} // end namespace io
} // end namespace irr
#endif // __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
#endif // __C_PAK_READER_H_INCLUDED__