CPkgReader.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // Created by almamu on 4/04/19.
  3. //
  4. #ifndef WALLENGINE_CPKGREADER_H
  5. #define WALLENGINE_CPKGREADER_H
  6. #include <irrlicht/irrlicht.h>
  7. #include <string>
  8. #include "CFileList.h"
  9. //! Archiveloader capable of loading WAD Archives
  10. class CArchiveLoaderPkg : public irr::io::IArchiveLoader
  11. {
  12. public:
  13. //! Constructor
  14. CArchiveLoaderPkg(irr::io::IFileSystem* fs);
  15. //! returns true if the file maybe is able to be loaded by this class
  16. //! based on the file extension (e.g. ".zip")
  17. virtual bool isALoadableFileFormat(const irr::io::path& filename) const;
  18. //! Check if the file might be loaded by this class
  19. /** Check might look into the file.
  20. \param file File handle to check.
  21. \return True if file seems to be loadable. */
  22. virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
  23. //! Check to see if the loader can create archives of this type.
  24. /** Check based on the archive type.
  25. \param fileType The archive type to check.
  26. \return True if the archile loader supports this type, false if not */
  27. virtual bool isALoadableFileFormat(irr::io::E_FILE_ARCHIVE_TYPE fileType) const;
  28. //! Creates an archive from the filename
  29. /** \param file File handle to check.
  30. \return Pointer to newly created archive, or 0 upon error. */
  31. virtual irr::io::IFileArchive* 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 irr::io::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. #endif //WALLENGINE_CPKGREADER_H