ZipArchiveIOSystem.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2025, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file ZipArchiveIOSystem.h
  35. * @brief Implementation of IOSystem to read a ZIP file from another IOSystem
  36. */
  37. #pragma once
  38. #ifndef AI_ZIPARCHIVEIOSYSTEM_H_INC
  39. #define AI_ZIPARCHIVEIOSYSTEM_H_INC
  40. #ifdef __GNUC__
  41. # pragma GCC system_header
  42. #endif
  43. #include <assimp/IOStream.hpp>
  44. #include <assimp/IOSystem.hpp>
  45. #include <zlib.h>
  46. namespace Assimp {
  47. class ZipArchiveIOSystem : public IOSystem {
  48. public:
  49. //! Open a Zip using the proffered IOSystem
  50. ZipArchiveIOSystem(IOSystem* pIOHandler, const char *pFilename, const char* pMode = "r");
  51. ZipArchiveIOSystem(IOSystem* pIOHandler, const std::string& rFilename, const char* pMode = "r");
  52. ~ZipArchiveIOSystem() override;
  53. bool Exists(const char* pFilename) const override;
  54. char getOsSeparator() const override;
  55. IOStream* Open(const char* pFilename, const char* pMode = "rb") override;
  56. void Close(IOStream* pFile) override;
  57. // Specific to ZIP
  58. //! The file was opened and is a ZIP
  59. bool isOpen() const;
  60. //! Get the list of all files with their simplified paths
  61. //! Intended for use within Assimp library boundaries
  62. void getFileList(std::vector<std::string>& rFileList) const;
  63. //! Get the list of all files with extension (must be lowercase)
  64. //! Intended for use within Assimp library boundaries
  65. void getFileListExtension(std::vector<std::string>& rFileList, const std::string& extension) const;
  66. static bool isZipArchive(IOSystem* pIOHandler, const char *pFilename);
  67. static bool isZipArchive(IOSystem* pIOHandler, const std::string& rFilename);
  68. private:
  69. class Implement;
  70. Implement *pImpl = nullptr;
  71. };
  72. } // Namespace Assimp
  73. #endif // AI_ZIPARCHIVEIOSYSTEM_H_INC