CPkgReader.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <irrlicht/irrlicht.h>
  3. #include <string>
  4. #include "CFileList.h"
  5. using namespace irr;
  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(irr::io::IFileSystem *fs);
  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. irr::io::IFileSystem *FileSystem;
  37. };
  38. class CPkgReader : public virtual irr::io::IFileArchive, virtual CFileList
  39. {
  40. public:
  41. //! constructor
  42. CPkgReader(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. irr::io::IFileSystem *mFileSystem;
  57. irr::io::IReadFile *mFile;
  58. };
  59. }