DatFile.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // Created by Иван_Архипов on 31.10.2017.
  3. //
  4. #ifndef LOTRO_DAT_PATCHER_DATFILE_H
  5. #define LOTRO_DAT_PATCHER_DATFILE_H
  6. #ifdef LOTRO_DAT_EXPORTS
  7. #define LOTRO_DAT_API __declspec(dllexport)
  8. #else
  9. #define LOTRO_DAT_API __declspec(dllimport)
  10. #endif
  11. #include <fstream>
  12. #include <map>
  13. #include <unordered_map>
  14. #include <set>
  15. extern "C++"
  16. {
  17. namespace LOTRO_DAT
  18. {
  19. class BinaryData;
  20. class DatException;
  21. class SubDirectory;
  22. class Subfile;
  23. enum STATE {
  24. CLOSED,
  25. SUCCESS_OPENED,
  26. SUCCESS_SUPERBLOCK,
  27. SUCCESS_DIRECTORIES,
  28. SUCCESS_DICTIONARY,
  29. READY
  30. };
  31. class DatFile
  32. {
  33. public:
  34. DatFile();
  35. explicit DatFile(const char* filename);
  36. explicit DatFile(const std::string &filename);
  37. ~DatFile();
  38. void ReadData(BinaryData &data, long long size, long long offset = 0, long long data_offset = 0);
  39. void WriteData(const BinaryData &data, long long size, long long offset = 0, long long data_offset = 0);
  40. long long constant1() const;
  41. long long constant2() const;
  42. long long file_size() const;
  43. long long version1() const;
  44. long long version2() const;
  45. const std::unordered_map<long long, Subfile*> &dictionary();
  46. private:
  47. FILE *file_handler_;
  48. SubDirectory *root_directory_;
  49. std::unordered_map<long long, Subfile*> dictionary_;
  50. void OpenDatFile(const char* dat_name);
  51. void ReadSuperBlock();
  52. void MakeDirectories();
  53. void MakeDictionary();
  54. long long constant1_;
  55. long long constant2_;
  56. long long file_size_;
  57. long long version1_;
  58. long long version2_;
  59. long long root_directory_offset_;
  60. STATE dat_state_;
  61. };
  62. }
  63. }
  64. #endif //LOTRO_DAT_PATCHER_DATFILE_H