CZipSaver.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. /*
  3. * CZipSaver.h, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. #include "COutputStream.h"
  12. #include "MinizipExtensions.h"
  13. class DLL_LINKAGE CZipOutputStream: public COutputStream
  14. {
  15. public:
  16. /**
  17. * @brief constructs zip stream from already opened file
  18. * @param archive archive handle, must be opened
  19. * @param archiveFilename name of file to write
  20. */
  21. explicit CZipOutputStream(zipFile archive, const std::string & archiveFilename);
  22. ~CZipOutputStream();
  23. si64 write(const ui8 * data, si64 size) override;
  24. si64 seek(si64 position) override {return -1;};
  25. si64 tell() override {return 0;};
  26. si64 skip(si64 delta) override {return 0;};
  27. si64 getSize() override {return 0;};
  28. private:
  29. zipFile handle;
  30. };
  31. class DLL_LINKAGE CZipSaver
  32. {
  33. public:
  34. explicit CZipSaver(std::shared_ptr<CIOApi> api, const std::string & path);
  35. virtual ~CZipSaver();
  36. std::unique_ptr<COutputStream> addFile(const std::string & archiveFilename);
  37. private:
  38. std::shared_ptr<CIOApi> ioApi;
  39. zlib_filefunc64_def zipApi;
  40. zipFile handle;
  41. ///due to minizip design only one file stream may opened at a time
  42. COutputStream * activeStream;
  43. };