DatFileSystem.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // Created by kikab on 04.06.2018.
  3. //
  4. #ifndef LOTRO_DAT_LIBRARY_DATFILESYSTEM_H
  5. #define LOTRO_DAT_LIBRARY_DATFILESYSTEM_H
  6. #include <set>
  7. #include <map>
  8. #include <utility>
  9. #include <memory>
  10. #include "DatOperationResult.h"
  11. extern "C++" {
  12. namespace LOTRO_DAT {
  13. class DatFile;
  14. class BinaryData;
  15. class SubDirectory;
  16. class SubFile;
  17. class DatFileSystem {
  18. public:
  19. DatFileSystem() = delete;
  20. DatFileSystem(const DatFileSystem &other) = delete;
  21. DatFileSystem& operator=(const DatFileSystem &other) = delete;
  22. ~DatFileSystem() = default;
  23. explicit DatFileSystem(DatFile *datFilePtr);
  24. DatOperationResult<> Init();
  25. DatOperationResult<BinaryData> GetFileData(long long file_id, long long int offset);
  26. DatOperationResult<SubFile> GetFile(long long file_id);
  27. DatOperationResult<bool> CheckCorrectSubfile(const SubFile &file);
  28. DatOperationResult<> UpdateFile(const SubFile& file);
  29. DatOperationResult<> DeInit();
  30. private:
  31. //------------------------------------------------//
  32. // PRIVATE INIT SECTION
  33. //------------------------------------------------//
  34. DatOperationResult<> MakeDirectories();
  35. DatOperationResult<> MakeDictionary();
  36. //------------------------------------------------//
  37. // PRIVATE DEINIT SECTION
  38. //------------------------------------------------//
  39. DatOperationResult<> CommitDirectories();
  40. private:
  41. DatFile *dat;
  42. std::shared_ptr<SubDirectory> root_directory_;
  43. std::set<long long> subfile_pending_update;
  44. std::map<long long, std::shared_ptr<SubFile> > dictionary_;
  45. };
  46. }
  47. };
  48. #endif //LOTRO_DAT_LIBRARY_DATFILESYSTEM_H