ArchiveZipEvent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_archivereader_domarchivezipevent_h__
  6. #define mozilla_dom_archivereader_domarchivezipevent_h__
  7. #include "mozilla/Attributes.h"
  8. #include "ArchiveEvent.h"
  9. #include "ArchiveReaderCommon.h"
  10. #include "zipstruct.h"
  11. BEGIN_ARCHIVEREADER_NAMESPACE
  12. /**
  13. * ArchiveZipItem - ArchiveItem for ArchiveReaderZipEvent
  14. */
  15. class ArchiveZipItem : public ArchiveItem
  16. {
  17. public:
  18. ArchiveZipItem(const char* aFilename,
  19. const ZipCentral& aCentralStruct,
  20. const nsACString& aEncoding);
  21. protected:
  22. virtual ~ArchiveZipItem();
  23. public:
  24. nsresult GetFilename(nsString& aFilename) override;
  25. // From zipItem to File:
  26. virtual already_AddRefed<File>
  27. GetFile(ArchiveReader* aArchiveReader) override;
  28. public: // for the event
  29. static uint32_t StrToInt32(const uint8_t* aStr);
  30. static uint16_t StrToInt16(const uint8_t* aStr);
  31. private:
  32. nsresult ConvertFilename();
  33. private: // data
  34. nsCString mFilename;
  35. nsString mFilenameU;
  36. ZipCentral mCentralStruct;
  37. nsCString mEncoding;
  38. };
  39. /**
  40. * ArchiveReaderEvent implements the ArchiveReaderEvent for the ZIP format
  41. */
  42. class ArchiveReaderZipEvent : public ArchiveReaderEvent
  43. {
  44. public:
  45. ArchiveReaderZipEvent(ArchiveReader* aArchiveReader,
  46. const nsACString& aEncoding);
  47. nsresult Exec() override;
  48. private:
  49. nsCString mEncoding;
  50. };
  51. END_ARCHIVEREADER_NAMESPACE
  52. #endif // mozilla_dom_archivereader_domarchivezipevent_h__