Переглянути джерело

Convert Q3BSP Importer to use ZipArchiveIOSystem

Removes duplication, handles large files better
RichardTea 6 роки тому
батько
коміт
3016f3a725

+ 0 - 2
code/CMakeLists.txt

@@ -690,8 +690,6 @@ ADD_ASSIMP_IMPORTER( Q3BSP
   Q3BSP/Q3BSPFileParser.cpp
   Q3BSP/Q3BSPFileImporter.h
   Q3BSP/Q3BSPFileImporter.cpp
-  Q3BSP/Q3BSPZipArchive.h
-  Q3BSP/Q3BSPZipArchive.cpp
 )
 
 ADD_ASSIMP_IMPORTER( RAW

+ 8 - 8
code/Q3BSP/Q3BSPFileImporter.cpp

@@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
 
 #include "Q3BSPFileImporter.h"
-#include "Q3BSPZipArchive.h"
 #include "Q3BSPFileParser.h"
 #include "Q3BSPFileData.h"
 
@@ -60,6 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <assimp/scene.h>
 #include <assimp/ai_assert.h>
 #include <assimp/DefaultIOSystem.h>
+#include <assimp/ZipArchiveIOSystem.h>
 #include <assimp/importerdesc.h>
 #include <vector>
 #include <sstream>
@@ -181,7 +181,7 @@ const aiImporterDesc* Q3BSPFileImporter::GetInfo () const {
 // ------------------------------------------------------------------------------------------------
 //  Import method.
 void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* scene, IOSystem* ioHandler) {
-    Q3BSPZipArchive Archive( ioHandler, rFile );
+    ZipArchiveIOSystem Archive( ioHandler, rFile );
     if ( !Archive.isOpen() ) {
         throw DeadlyImportError( "Failed to open file " + rFile + "." );
     }
@@ -223,10 +223,10 @@ void Q3BSPFileImporter::separateMapName( const std::string &importName, std::str
 
 // ------------------------------------------------------------------------------------------------
 //  Returns the first map in the map archive.
-bool Q3BSPFileImporter::findFirstMapInArchive( Q3BSPZipArchive &bspArchive, std::string &mapName ) {
+bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, std::string &mapName ) {
     mapName = "";
     std::vector<std::string> fileList;
-    bspArchive.getFileList( fileList );
+    bspArchive.getFileListExtension( fileList, "bsp" );
     if (fileList.empty()) {
         return false;
     }
@@ -249,7 +249,7 @@ bool Q3BSPFileImporter::findFirstMapInArchive( Q3BSPZipArchive &bspArchive, std:
 // ------------------------------------------------------------------------------------------------
 //  Creates the assimp specific data.
 void Q3BSPFileImporter::CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
-        Q3BSPZipArchive *pArchive ) {
+    ZipArchiveIOSystem *pArchive ) {
     if (nullptr == pModel || nullptr == pScene) {
         return;
     }
@@ -418,7 +418,7 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel,
 // ------------------------------------------------------------------------------------------------
 //  Creates all referenced materials.
 void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
-        Q3BSPZipArchive *pArchive ) {
+    ZipArchiveIOSystem *pArchive ) {
     if ( m_MaterialLookupMap.empty() ) {
         return;
     }
@@ -564,7 +564,7 @@ aiFace *Q3BSPFileImporter::getNextFace( aiMesh *mesh, unsigned int &faceIdx ) {
 // ------------------------------------------------------------------------------------------------
 //  Imports a texture file.
 bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model,
-                                                 Q3BSP::Q3BSPZipArchive *archive, aiScene*,
+                                                 ZipArchiveIOSystem *archive, aiScene*,
                                                  aiMaterial *pMatHelper, int textureId ) {
     if (nullptr == archive || nullptr == pMatHelper ) {
         return false;
@@ -669,7 +669,7 @@ bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene
 
 // ------------------------------------------------------------------------------------------------
 //  Will search for a supported extension.
-bool Q3BSPFileImporter::expandFile(  Q3BSP::Q3BSPZipArchive *pArchive, const std::string &rFilename,
+bool Q3BSPFileImporter::expandFile(ZipArchiveIOSystem *pArchive, const std::string &rFilename,
                                    const std::vector<std::string> &rExtList, std::string &rFile,
                                    std::string &rExt )
 {

+ 6 - 6
code/Q3BSP/Q3BSPFileImporter.h

@@ -54,9 +54,9 @@ struct aiMaterial;
 struct aiTexture;
 
 namespace Assimp {
+    class ZipArchiveIOSystem;
 
 namespace Q3BSP {
-    class Q3BSPZipArchive;
     struct Q3BSPModel;
     struct sQ3BSPFace;
 }
@@ -85,24 +85,24 @@ protected:
     const aiImporterDesc* GetInfo () const;
     void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
     void separateMapName( const std::string &rImportName, std::string &rArchiveName, std::string &rMapName );
-    bool findFirstMapInArchive( Q3BSP::Q3BSPZipArchive &rArchive, std::string &rMapName );
-    void CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
+    bool findFirstMapInArchive(ZipArchiveIOSystem &rArchive, std::string &rMapName );
+    void CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, ZipArchiveIOSystem *pArchive );
     void CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, aiNode *pParent );
     aiNode *CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx,
         std::vector<Q3BSP::sQ3BSPFace*> &rArray, aiMesh  **pMesh );
     void createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, Q3BSP::sQ3BSPFace *pQ3BSPFace, aiMesh* pMesh, unsigned int &rFaceIdx,
         unsigned int &rVertIdx  );
-    void createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
+    void createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, ZipArchiveIOSystem *pArchive );
     size_t countData( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const;
     size_t countFaces( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const;
     size_t countTriangles( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const;
     void createMaterialMap( const Q3BSP::Q3BSPModel *pModel);
     aiFace *getNextFace( aiMesh *pMesh, unsigned int &rFaceIdx );
-    bool importTextureFromArchive( const Q3BSP::Q3BSPModel *pModel, Q3BSP::Q3BSPZipArchive *pArchive, aiScene* pScene,
+    bool importTextureFromArchive( const Q3BSP::Q3BSPModel *pModel, ZipArchiveIOSystem *pArchive, aiScene* pScene,
         aiMaterial *pMatHelper, int textureId );
     bool importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, aiMaterial *pMatHelper, int lightmapId );
     bool importEntities( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene );
-    bool expandFile(  Q3BSP::Q3BSPZipArchive *pArchive, const std::string &rFilename, const std::vector<std::string> &rExtList,
+    bool expandFile(ZipArchiveIOSystem *pArchive, const std::string &rFilename, const std::vector<std::string> &rExtList,
         std::string &rFile, std::string &rExt );
 
 private:

+ 3 - 2
code/Q3BSP/Q3BSPFileParser.cpp

@@ -45,9 +45,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "Q3BSPFileParser.h"
 #include "Q3BSPFileData.h"
-#include "Q3BSPZipArchive.h"
 #include <vector>
 #include <assimp/DefaultIOSystem.h>
+#include <assimp/ZipArchiveIOSystem.h>
 #include <assimp/ai_assert.h>
 
 namespace Assimp {
@@ -55,7 +55,7 @@ namespace Assimp {
 using namespace Q3BSP;
 
 // ------------------------------------------------------------------------------------------------
-Q3BSPFileParser::Q3BSPFileParser( const std::string &mapName, Q3BSPZipArchive *pZipArchive ) :
+Q3BSPFileParser::Q3BSPFileParser( const std::string &mapName, ZipArchiveIOSystem *pZipArchive ) :
     m_sOffset( 0 ),
     m_Data(),
     m_pModel(nullptr),
@@ -101,6 +101,7 @@ bool Q3BSPFileParser::readData( const std::string &rMapName ) {
     const size_t readSize = pMapFile->Read( &m_Data[0], sizeof( char ), size );
     if ( readSize != size ) {
         m_Data.clear();
+        m_pZipArchive->Close(pMapFile);
         return false;
     }
     m_pZipArchive->Close( pMapFile );

+ 6 - 7
code/Q3BSP/Q3BSPFileParser.h

@@ -48,13 +48,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 namespace Assimp
 {
+    class ZipArchiveIOSystem;
+
 namespace Q3BSP
 {
-
-class Q3BSPZipArchive;
-struct Q3BSPModel;
-class ZipFile;
-
+    struct Q3BSPModel;
+    class ZipFile;
 }
 
 // -------------------------------------------------------------------
@@ -62,7 +61,7 @@ class ZipFile;
 class Q3BSPFileParser
 {
 public:
-    Q3BSPFileParser( const std::string &rMapName, Q3BSP::Q3BSPZipArchive *pZipArchive );
+    Q3BSPFileParser( const std::string &rMapName, ZipArchiveIOSystem *pZipArchive );
     ~Q3BSPFileParser();
     Q3BSP::Q3BSPModel *getModel() const;
 
@@ -83,7 +82,7 @@ private:
     size_t m_sOffset;
     std::vector<char> m_Data;
     Q3BSP::Q3BSPModel *m_pModel;
-    Q3BSP::Q3BSPZipArchive *m_pZipArchive;
+    ZipArchiveIOSystem *m_pZipArchive;
 };
 
 } // Namespace Assimp

+ 0 - 325
code/Q3BSP/Q3BSPZipArchive.cpp

@@ -1,325 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2019, assimp team
-
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
-  copyright notice, this list of conditions and the
-  following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the
-  following disclaimer in the documentation and/or other
-  materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
-  contributors may be used to endorse or promote products
-  derived from this software without specific prior
-  written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-
-#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
-
-#include "Q3BSPZipArchive.h"
-#include <cassert>
-#include <cstdlib>
-#include <assimp/ai_assert.h>
-
-namespace Assimp {
-namespace Q3BSP {
-
-voidpf IOSystem2Unzip::open(voidpf opaque, const char* filename, int mode) {
-    IOSystem* io_system = (IOSystem*) opaque;
-
-    const char* mode_fopen = NULL;
-    if((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) {
-        mode_fopen = "rb";
-    } else {
-        if(mode & ZLIB_FILEFUNC_MODE_EXISTING) {
-            mode_fopen = "r+b";
-        } else {
-            if(mode & ZLIB_FILEFUNC_MODE_CREATE) {
-                mode_fopen = "wb";
-            }
-        }
-    }
-
-    return (voidpf) io_system->Open(filename, mode_fopen);
-}
-
-uLong IOSystem2Unzip::read(voidpf /*opaque*/, voidpf stream, void* buf, uLong size) {
-    IOStream* io_stream = (IOStream*) stream;
-
-    return static_cast<uLong>(io_stream->Read(buf, 1, size));
-}
-
-uLong IOSystem2Unzip::write(voidpf /*opaque*/, voidpf stream, const void* buf, uLong size) {
-    IOStream* io_stream = (IOStream*) stream;
-
-    return static_cast<uLong>(io_stream->Write(buf, 1, size));
-}
-
-long IOSystem2Unzip::tell(voidpf /*opaque*/, voidpf stream) {
-    IOStream* io_stream = (IOStream*) stream;
-
-    return static_cast<long>(io_stream->Tell());
-}
-
-long IOSystem2Unzip::seek(voidpf /*opaque*/, voidpf stream, uLong offset, int origin) {
-    IOStream* io_stream = (IOStream*) stream;
-
-    aiOrigin assimp_origin;
-    switch (origin) {
-        default:
-        case ZLIB_FILEFUNC_SEEK_CUR:
-            assimp_origin = aiOrigin_CUR;
-            break;
-        case ZLIB_FILEFUNC_SEEK_END:
-            assimp_origin = aiOrigin_END;
-            break;
-        case ZLIB_FILEFUNC_SEEK_SET:
-            assimp_origin = aiOrigin_SET;
-            break;
-    }
-
-    return (io_stream->Seek(offset, assimp_origin) == aiReturn_SUCCESS ? 0 : -1);
-}
-
-int IOSystem2Unzip::close(voidpf opaque, voidpf stream) {
-    IOSystem* io_system = (IOSystem*) opaque;
-    IOStream* io_stream = (IOStream*) stream;
-
-    io_system->Close(io_stream);
-
-    return 0;
-}
-
-int IOSystem2Unzip::testerror(voidpf /*opaque*/, voidpf /*stream*/) {
-    return 0;
-}
-
-zlib_filefunc_def IOSystem2Unzip::get(IOSystem* pIOHandler) {
-    zlib_filefunc_def mapping;
-
-#ifdef ASSIMP_USE_HUNTER
-    mapping.zopen_file = (open_file_func)open;
-    mapping.zread_file = (read_file_func)read;
-    mapping.zwrite_file = (write_file_func)write;
-    mapping.ztell_file = (tell_file_func)tell;
-    mapping.zseek_file = (seek_file_func)seek;
-    mapping.zclose_file = (close_file_func)close;
-    mapping.zerror_file = (error_file_func)testerror;
-#else
-    mapping.zopen_file = open;
-    mapping.zread_file = read;
-    mapping.zwrite_file = write;
-    mapping.ztell_file = tell;
-    mapping.zseek_file = seek;
-    mapping.zclose_file = close;
-    mapping.zerror_file = testerror;
-#endif
-    mapping.opaque = (voidpf) pIOHandler;
-
-    return mapping;
-}
-
-ZipFile::ZipFile(size_t size) : m_Size(size) {
-    ai_assert(m_Size != 0);
-
-    m_Buffer = malloc(m_Size);
-}
-
-ZipFile::~ZipFile() {
-    free(m_Buffer);
-    m_Buffer = NULL;
-}
-
-size_t ZipFile::Read(void* pvBuffer, size_t pSize, size_t pCount) {
-    const size_t size = pSize * pCount;
-    assert(size <= m_Size);
-
-    std::memcpy(pvBuffer, m_Buffer, size);
-
-    return size;
-}
-
-size_t ZipFile::Write(const void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) {
-    return 0;
-}
-
-size_t ZipFile::FileSize() const {
-    return m_Size;
-}
-
-aiReturn ZipFile::Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) {
-    return aiReturn_FAILURE;
-}
-
-size_t ZipFile::Tell() const {
-    return 0;
-}
-
-void ZipFile::Flush() {
-    // empty
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Constructor.
-Q3BSPZipArchive::Q3BSPZipArchive(IOSystem* pIOHandler, const std::string& rFile) : m_ZipFileHandle(NULL), m_ArchiveMap() {
-    if (! rFile.empty()) {
-        zlib_filefunc_def mapping = IOSystem2Unzip::get(pIOHandler);
-
-        m_ZipFileHandle = unzOpen2(rFile.c_str(), &mapping);
-
-        if(m_ZipFileHandle != nullptr) {
-            mapArchive();
-        }
-    }
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Destructor.
-Q3BSPZipArchive::~Q3BSPZipArchive() {
-    for(auto &file : m_ArchiveMap) {
-        delete file.second;
-    }
-    m_ArchiveMap.clear();
-
-    if(m_ZipFileHandle != nullptr) {
-        unzClose(m_ZipFileHandle);
-        m_ZipFileHandle = nullptr;
-    }
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Returns true, if the archive is already open.
-bool Q3BSPZipArchive::isOpen() const {
-    return (m_ZipFileHandle != nullptr);
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Returns true, if the filename is part of the archive.
-bool Q3BSPZipArchive::Exists(const char* pFile) const {
-    bool exist = false;
-    if (pFile != nullptr) {
-        std::string rFile(pFile);
-        std::map<std::string, ZipFile*>::const_iterator it = m_ArchiveMap.find(rFile);
-
-        if(it != m_ArchiveMap.end()) {
-            exist = true;
-        }
-    }
-
-    return exist;
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Returns the separator delimiter.
-char Q3BSPZipArchive::getOsSeparator() const {
-#ifndef _WIN32
-    return '/';
-#else
-    return '\\';
-#endif
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Opens a file, which is part of the archive.
-IOStream *Q3BSPZipArchive::Open(const char* pFile, const char* /*pMode*/) {
-    ai_assert(pFile != nullptr);
-
-    IOStream* result = nullptr;
-
-    std::map<std::string, ZipFile*>::iterator it = m_ArchiveMap.find(pFile);
-
-    if(it != m_ArchiveMap.end()) {
-        result = (IOStream*) it->second;
-    }
-
-    return result;
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Close a filestream.
-void Q3BSPZipArchive::Close(IOStream *pFile) {
-    (void)(pFile);
-    ai_assert(pFile != nullptr);
-
-    // We don't do anything in case the file would be opened again in the future
-}
-// ------------------------------------------------------------------------------------------------
-//  Returns the file-list of the archive.
-void Q3BSPZipArchive::getFileList(std::vector<std::string> &rFileList) {
-    rFileList.clear();
-
-    for(auto &file : m_ArchiveMap) {
-        rFileList.push_back(file.first);
-    }
-}
-
-// ------------------------------------------------------------------------------------------------
-//  Maps the archive content.
-bool Q3BSPZipArchive::mapArchive() {
-    bool success = false;
-
-    if(m_ZipFileHandle != nullptr) {
-        if(m_ArchiveMap.empty()) {
-            //  At first ensure file is already open
-            if(unzGoToFirstFile(m_ZipFileHandle) == UNZ_OK) {
-                // Loop over all files
-                do {
-                    char filename[FileNameSize];
-                    unz_file_info fileInfo;
-
-                    if(unzGetCurrentFileInfo(m_ZipFileHandle, &fileInfo, filename, FileNameSize, NULL, 0, NULL, 0) == UNZ_OK) {
-                        // The file has EXACTLY the size of uncompressed_size. In C
-                        // you need to mark the last character with '\0', so add
-                        // another character
-                        if(fileInfo.uncompressed_size != 0 && unzOpenCurrentFile(m_ZipFileHandle) == UNZ_OK) {
-                            std::pair<std::map<std::string, ZipFile*>::iterator, bool> result = m_ArchiveMap.insert(std::make_pair(filename, new ZipFile(fileInfo.uncompressed_size)));
-
-                            if(unzReadCurrentFile(m_ZipFileHandle, result.first->second->m_Buffer, fileInfo.uncompressed_size) == (long int) fileInfo.uncompressed_size) {
-                                if(unzCloseCurrentFile(m_ZipFileHandle) == UNZ_OK) {
-                                    // Nothing to do anymore...
-                                }
-                            }
-                        }
-                    }
-                } while(unzGoToNextFile(m_ZipFileHandle) != UNZ_END_OF_LIST_OF_FILE);
-            }
-        }
-
-        success = true;
-    }
-
-    return success;
-}
-
-// ------------------------------------------------------------------------------------------------
-
-} // Namespace Q3BSP
-} // Namespace Assimp
-
-#endif // ASSIMP_BUILD_NO_Q3BSP_IMPORTER

+ 0 - 135
code/Q3BSP/Q3BSPZipArchive.h

@@ -1,135 +0,0 @@
-/*
-Open Asset Import Library (assimp)
-----------------------------------------------------------------------
-
-Copyright (c) 2006-2019, assimp team
-
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms,
-with or without modification, are permitted provided that the
-following conditions are met:
-
-* Redistributions of source code must retain the above
-  copyright notice, this list of conditions and the
-  following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the
-  following disclaimer in the documentation and/or other
-  materials provided with the distribution.
-
-* Neither the name of the assimp team, nor the names of its
-  contributors may be used to endorse or promote products
-  derived from this software without specific prior
-  written permission of the assimp team.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
-*/
-#ifndef AI_Q3BSP_ZIPARCHIVE_H_INC
-#define AI_Q3BSP_ZIPARCHIVE_H_INC
-
-#ifdef ASSIMP_USE_HUNTER
-#  include <minizip/unzip.h>
-#else
-#  include <unzip.h>
-#endif
-#include <assimp/IOStream.hpp>
-#include <assimp/IOSystem.hpp>
-#include <vector>
-#include <map>
-#include <cassert>
-
-namespace Assimp {
-namespace Q3BSP {
-
-// ------------------------------------------------------------------------------------------------
-/// \class      IOSystem2Unzip
-/// \ingroup    Assimp::Q3BSP
-///
-/// \brief
-// ------------------------------------------------------------------------------------------------
-class IOSystem2Unzip {
-public:
-    static voidpf open(voidpf opaque, const char* filename, int mode);
-    static uLong read(voidpf opaque, voidpf stream, void* buf, uLong size);
-    static uLong write(voidpf opaque, voidpf stream, const void* buf, uLong size);
-    static long tell(voidpf opaque, voidpf stream);
-    static long seek(voidpf opaque, voidpf stream, uLong offset, int origin);
-    static int close(voidpf opaque, voidpf stream);
-    static int testerror(voidpf opaque, voidpf stream);
-    static zlib_filefunc_def get(IOSystem* pIOHandler);
-};
-
-// ------------------------------------------------------------------------------------------------
-/// \class      ZipFile
-/// \ingroup    Assimp::Q3BSP
-///
-/// \brief
-// ------------------------------------------------------------------------------------------------
-class ZipFile : public IOStream {
-    friend class Q3BSPZipArchive;
-
-public:
-    explicit ZipFile(size_t size);
-    ~ZipFile();
-    size_t Read(void* pvBuffer, size_t pSize, size_t pCount );
-    size_t Write(const void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/);
-    size_t FileSize() const;
-    aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/);
-    size_t Tell() const;
-    void Flush();
-
-private:
-    void* m_Buffer;
-    size_t m_Size;
-};
-
-// ------------------------------------------------------------------------------------------------
-/// \class      Q3BSPZipArchive
-/// \ingroup    Assimp::Q3BSP
-///
-/// \brief  IMplements a zip archive like the WinZip archives. Will be also used to import data
-/// from a P3K archive ( Quake level format ).
-// ------------------------------------------------------------------------------------------------
-class Q3BSPZipArchive : public Assimp::IOSystem {
-public:
-    static const unsigned int FileNameSize = 256;
-
-public:
-    Q3BSPZipArchive(IOSystem* pIOHandler, const std::string & rFile);
-    ~Q3BSPZipArchive();
-    bool Exists(const char* pFile) const;
-    char getOsSeparator() const;
-    IOStream* Open(const char* pFile, const char* pMode = "rb");
-    void Close(IOStream* pFile);
-    bool isOpen() const;
-    void getFileList(std::vector<std::string> &rFileList);
-
-private:
-    bool mapArchive();
-
-private:
-    unzFile m_ZipFileHandle;
-    std::map<std::string, ZipFile*> m_ArchiveMap;
-};
-
-// ------------------------------------------------------------------------------------------------
-
-} // Namespace Q3BSP
-} // Namespace Assimp
-
-#endif // AI_Q3BSP_ZIPARCHIVE_H_INC