datfile.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "datexportapi.h"
  2. #include "database.h"
  3. #include "subfile.h"
  4. #include <string>
  5. #include <functional>
  6. namespace LOTRO_DAT {
  7. struct SubfileInfo {
  8. int file_id;
  9. int size;
  10. int iteration;
  11. friend bool operator<(const SubfileInfo& info1, const SubfileInfo& info2) {
  12. return info1.file_id < info2.file_id;
  13. }
  14. };
  15. class DatFile;
  16. typedef std::function<void (const SubfileInfo&)> SubfileOperation;
  17. class DatFile {
  18. public:
  19. DatFile(int file_handle);
  20. ~DatFile();
  21. bool Init(const std::string& filename);
  22. void LoadAllFilesInfo();
  23. void Deinit();
  24. bool Initialized() const;
  25. const std::string& GetFilename() const;
  26. size_t GetFilesNumInDatFile();
  27. size_t PatchAllFilesFromDatabase(Database& db);
  28. void PatchFile(SubfileData file_data);
  29. void PatchFile(int file_id, FILE_TYPE type, std::string path_to_file);
  30. FILE_TYPE GetExistingFileType(int file_id);
  31. void PerformOperationOnAllSubfiles(const SubfileOperation& operation);
  32. int ExportFilesByType(FILE_TYPE type, Database& db);
  33. int ExportFilesByType(FILE_TYPE type, std::string path_to_directory);
  34. void ExportFileById(int file_id, Database& db);
  35. void ExportFileById(int file_id, std::string target_file_path);
  36. private:
  37. static DatExportApi api_;
  38. int file_handle_;
  39. bool initialized_;
  40. std::set<SubfileInfo> files_info_;
  41. std::string filename_;
  42. BinaryData export_data_buf_;
  43. };
  44. } // namespace LOTRO_DAT