SubFile.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // Created by Иван_Архипов on 01.11.2017.
  3. //
  4. #ifndef LOTRO_DAT_PATCHER_SUBFILE_H
  5. #define LOTRO_DAT_PATCHER_SUBFILE_H
  6. #include <string>
  7. #include <vector>
  8. #include "yaml-cpp/yaml.h"
  9. extern "C++"
  10. {
  11. namespace LOTRO_DAT
  12. {
  13. class DatFile;
  14. class BinaryData;
  15. class Database;
  16. class SubfileData;
  17. enum FILE_TYPE : int;
  18. class SubFile
  19. {
  20. friend class DatFileSystem;
  21. friend class DatPatcher;
  22. public:
  23. struct SubFileOffsetComparator {
  24. bool operator() (const SubFile &f, const SubFile &s){
  25. return f.file_offset_ < s.file_offset_;
  26. }
  27. };
  28. SubFile();
  29. SubFile(const SubFile &other) = default;
  30. SubFile &operator =(const SubFile &other) = default;
  31. SubFile(DatFile &dat, const BinaryData &header);
  32. SubFile(DatFile &dat, long long dictionary_offset, long long fragments_count, long long unknown1,
  33. long long file_id, long long file_offset, long long file_size, long long timestamp, long long version,
  34. long long block_size);
  35. virtual ~SubFile() = default;
  36. virtual FILE_TYPE FileType() const;
  37. virtual std::string Extension() const;
  38. virtual SubfileData PrepareForExport(const BinaryData &file_data);
  39. virtual BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data);
  40. BinaryData MakeHeaderData() const;
  41. long long dictionary_offset() const;
  42. long long unknown1() const;
  43. long long file_id() const;
  44. long long file_offset() const;
  45. long long file_size() const;
  46. long long timestamp() const;
  47. long long version() const;
  48. long long block_size() const;
  49. long long unknown2() const;
  50. bool operator ==(const SubFile &b) const;
  51. bool operator !=(const SubFile &b) const;
  52. static FILE_TYPE GetSubfileType(DatFile& dat, SubFile preinit_file);
  53. static std::shared_ptr<SubFile> MakeSubfile(DatFile& dat, SubFile preinit_file);
  54. long long category;
  55. protected:
  56. DatFile *dat_;
  57. long long dictionary_offset_;
  58. long long unknown1_;
  59. long long file_id_;
  60. long long file_offset_;
  61. long long file_size_;
  62. long long timestamp_;
  63. long long version_;
  64. long long block_size_;
  65. long long unknown2_;
  66. };
  67. }
  68. };
  69. #endif //LOTRO_DAT_PATCHER_SUBFILE_H