DatFile.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. explicit DatFile(const char* filename);
  35. explicit DatFile(const std::string &filename);
  36. ~DatFile();
  37. void ReadData(BinaryData &data, long long size, long long offset = 0, long long data_offset = 0);
  38. void WriteData(const BinaryData &data, long long size, long long offset = 0, long long data_offset = 0);
  39. long long constant1() const;
  40. long long constant2() const;
  41. long long file_size() const;
  42. long long version1() const;
  43. long long version2() const;
  44. const std::unordered_map<long long, Subfile*> &dictionary();
  45. private:
  46. FILE *file_handler_;
  47. SubDirectory *root_directory_;
  48. std::unordered_map<long long, Subfile*> dictionary_;
  49. void OpenDatFile(const char* dat_name);
  50. void ReadSuperBlock();
  51. void MakeDirectories();
  52. void MakeDictionary();
  53. long long constant1_;
  54. long long constant2_;
  55. long long file_size_;
  56. long long version1_;
  57. long long version2_;
  58. long long root_directory_offset_;
  59. STATE dat_state_;
  60. };
  61. }
  62. }
  63. #endif //LOTRO_DAT_PATCHER_DATFILE_H