CPkgReader.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include <irrlicht/irrlicht.h>
  3. #include <string>
  4. #include "CContext.h"
  5. #include "CFileList.h"
  6. namespace WallpaperEngine::Irrlicht
  7. {
  8. //! Archiveloader capable of loading WAD Archives
  9. class CArchiveLoaderPkg : public irr::io::IArchiveLoader
  10. {
  11. public:
  12. //! Constructor
  13. CArchiveLoaderPkg (CContext* context);
  14. //! returns true if the file maybe is able to be loaded by this class
  15. //! based on the file extension (e.g. ".zip")
  16. virtual bool isALoadableFileFormat (const irr::io::path &filename) const;
  17. //! Check if the file might be loaded by this class
  18. /** Check might look into the file.
  19. \param file File handle to check.
  20. \return True if file seems to be loadable. */
  21. virtual bool isALoadableFileFormat (irr::io::IReadFile *file) const;
  22. //! Check to see if the loader can create archives of this type.
  23. /** Check based on the archive type.
  24. \param fileType The archive type to check.
  25. \return True if the archile loader supports this type, false if not */
  26. virtual bool isALoadableFileFormat (irr::io::E_FILE_ARCHIVE_TYPE fileType) const;
  27. //! Creates an archive from the filename
  28. /** \param file File handle to check.
  29. \return Pointer to newly created archive, or 0 upon error. */
  30. virtual irr::io::IFileArchive *
  31. createArchive (const irr::io::path &filename, bool ignoreCase, bool ignorePaths) const;
  32. //! creates/loads an archive from the file.
  33. //! \return Pointer to the created archive. Returns 0 if loading failed.
  34. virtual irr::io::IFileArchive *createArchive (irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths) const;
  35. private:
  36. CContext* m_context;
  37. };
  38. class CPkgReader : public virtual irr::io::IFileArchive, virtual CFileList
  39. {
  40. public:
  41. //! constructor
  42. CPkgReader (CContext* context, irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths);
  43. //! destructor
  44. virtual ~CPkgReader ();
  45. //! opens a file by file name
  46. virtual irr::io::IReadFile *createAndOpenFile (const irr::io::path &filename);
  47. //! opens a file by index
  48. virtual irr::io::IReadFile *createAndOpenFile (unsigned int index);
  49. //! returns the list of files
  50. virtual const IFileList *getFileList () const;
  51. //! get the archive type
  52. virtual irr::io::E_FILE_ARCHIVE_TYPE getType () const;
  53. protected:
  54. void scanPkgHeader ();
  55. char *readSizedString ();
  56. CContext* m_context;
  57. irr::io::IReadFile *m_file;
  58. };
  59. }