PakFile.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef CRYINCLUDE_EDITOR_UTIL_PAKFILE_H
  9. #define CRYINCLUDE_EDITOR_UTIL_PAKFILE_H
  10. #pragma once
  11. #include <AzFramework/Archive/INestedArchive.h>
  12. class CCryMemFile;
  13. // forward references.
  14. namespace AZ::IO
  15. {
  16. struct IArchive;
  17. }
  18. /*! CPakFile Wraps game implementation of INestedArchive.
  19. Used for storing multiple files into zip archive file.
  20. */
  21. class SANDBOX_API CPakFile
  22. {
  23. public:
  24. CPakFile();
  25. CPakFile(AZ::IO::IArchive* pCryPak);
  26. ~CPakFile();
  27. //! Opens archive for writing.
  28. explicit CPakFile(const char* filename);
  29. //! Opens archive for writing.
  30. bool Open(const char* filename, bool bAbsolutePath = true);
  31. //! Opens archive for reading only.
  32. bool OpenForRead(const char* filename);
  33. void Close();
  34. //! Adds or update file in archive.
  35. bool UpdateFile(const char* filename, CCryMemFile& file, bool bCompress = true);
  36. //! Adds or update file in archive.
  37. bool UpdateFile(const char* filename, CMemoryBlock& mem, bool bCompress = true, int nCompressLevel = AZ::IO::INestedArchive::LEVEL_BETTER);
  38. //! Adds or update file in archive.
  39. bool UpdateFile(const char* filename, void* pBuffer, int nSize, bool bCompress = true, int nCompressLevel = AZ::IO::INestedArchive::LEVEL_BETTER);
  40. //! Remove file from archive.
  41. bool RemoveFile(const char* filename);
  42. //! Remove dir from archive.
  43. bool RemoveDir(const char* directory);
  44. //! Return archive of this pak file wrapper.
  45. AZ::IO::INestedArchive* GetArchive() { return m_pArchive.get(); };
  46. private:
  47. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  48. AZStd::intrusive_ptr<AZ::IO::INestedArchive> m_pArchive;
  49. AZ::IO::IArchive* m_pCryPak;
  50. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  51. };
  52. #endif // CRYINCLUDE_EDITOR_UTIL_PAKFILE_H