QGearsLGPArchive.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. -----------------------------------------------------------------------------
  3. The MIT License (MIT)
  4. Copyright (c) 2013-09-22 Tobias Peters <tobias.peters@kreativeffekt.at>
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. -----------------------------------------------------------------------------
  21. */
  22. #ifndef __QGearsLGPArchive_H__
  23. #define __QGearsLGPArchive_H__
  24. #include <OgreArchive.h>
  25. #include "common/TypeDefine.h"
  26. namespace QGears
  27. {
  28. class LGPArchive : public Ogre::Archive
  29. {
  30. public:
  31. LGPArchive( const String &name, const String &archType );
  32. virtual ~LGPArchive();
  33. /// @copydoc Ogre::Archive::isCaseSensitive
  34. bool isCaseSensitive(void) const { return true; }
  35. /// @copydoc Ogre::Archive::load
  36. void load();
  37. /// @copydoc Ogre::Archive::unload
  38. void unload();
  39. /// @copydoc Ogre::Archive::open
  40. Ogre::DataStreamPtr open(const String& filename, bool readOnly = true) const;
  41. /// @copydoc Archive::create
  42. Ogre::DataStreamPtr create(const String& filename) const;
  43. /// @copydoc Archive::remove
  44. void remove(const String& filename) const;
  45. /// @copydoc Archive::list
  46. Ogre::StringVectorPtr list(bool recursive = true, bool dirs = false) const;
  47. /// @copydoc Archive::listFileInfo
  48. Ogre::FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false) const;
  49. /// @copydoc Archive::find
  50. Ogre::StringVectorPtr find(const String& pattern, bool recursive = true,
  51. bool dirs = false) const;
  52. /// @copydoc Archive::findFileInfo
  53. Ogre::FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true,
  54. bool dirs = false) const;
  55. /// @copydoc Archive::exists
  56. bool exists(const String& filename) const;
  57. /// @copydoc Archive::getModifiedTime
  58. time_t getModifiedTime(const String& filename) const;
  59. struct FileEntry
  60. {
  61. String file_name;
  62. uint32 fileoffset_;
  63. uint8 unknown1;
  64. uint16 unknown2;
  65. String datafile_name_;
  66. uint32 data_size;
  67. uint32 dataoffset_;
  68. };
  69. typedef std::vector<FileEntry> FileList;
  70. virtual FileList& getFiles( void );
  71. protected:
  72. void load( Ogre::DataStream* lgp );
  73. private:
  74. FileList m_files;
  75. Ogre::DataStreamPtr m_lgp_file;
  76. Ogre::FileInfoList m_file_infos;
  77. };
  78. }
  79. #endif // __QGearsLGPArchive_H__