123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include "datexportapi.h"
- #include "database.h"
- #include "subfile.h"
- #include <string>
- #include <functional>
- namespace LOTRO_DAT {
- struct SubfileInfo {
- int file_id = -1;
- int size = -1;
- int iteration = -1;
- friend bool operator<(const SubfileInfo& info1, const SubfileInfo& info2) {
- return info1.file_id < info2.file_id;
- }
- };
- class DatFile;
- typedef std::function<void (const SubfileInfo&)> SubfileOperation;
- class DatFile {
- public:
- DatFile(int file_handle);
- ~DatFile();
- bool Init(const std::string& filename);
- void LoadAllFilesInfo();
- void Deinit();
-
- static bool checkIfPatchedByLegacyV1(const std::string& filename);
-
- bool Initialized() const;
- const std::string& GetFilename() const;
-
- int GetDatFileMaxIteration() const;
- SubfileInfo getSubfileInfo(int file_id) const;
- size_t GetFilesNumInDatFile();
- size_t PatchAllFilesFromDatabase(Database& db);
- void PatchFile(SubfileData file_data, int version = -1, int iteration = -1, bool create = false);
- void PatchFile(int file_id, FILE_TYPE type, std::string path_to_file, int version = -1, int iteration = -1);
- FILE_TYPE GetExistingFileType(int file_id);
- void PerformOperationOnAllSubfiles(const SubfileOperation& operation);
- int ExportFilesByType(FILE_TYPE type, Database& db);
- int ExportFilesByType(FILE_TYPE type, std::string path_to_directory);
-
- void ExportFileById(int file_id, Database& db);
- void ExportFileById(int file_id, std::string target_file_path);
- int GetFileVersion(int file_id);
- SubfileData GetFile(int file_id);
- private:
- static DatExportApi api_;
- int file_handle_;
- bool initialized_;
- std::map<int, SubfileInfo> files_info_;
- std::string filename_;
- BinaryData export_data_buf_;
- };
- } // namespace LOTRO_DAT
|