SubDirectory.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Created by Иван_Архипов on 07.11.2017.
  3. //
  4. #ifndef LOTRO_DAT_PATCHER_SUBDIRECTORY_H
  5. #define LOTRO_DAT_PATCHER_SUBDIRECTORY_H
  6. #include <vector>
  7. #include <map>
  8. #include <queue>
  9. #include <unordered_map>
  10. #include <unordered_set>
  11. #include "SubFile.h"
  12. extern "C++"
  13. {
  14. namespace LOTRO_DAT
  15. {
  16. enum FILE_TYPE : int;
  17. class DatFile;
  18. class BinaryData;
  19. class SubFile;
  20. class SubDirectory
  21. {
  22. public:
  23. struct SubDirectoryOffsetComp {
  24. bool operator() (const SubDirectory* f, const SubDirectory *s){
  25. if (!f || !s)
  26. return false;
  27. return f->offset_ < s->offset_;
  28. }
  29. };
  30. SubDirectory() = delete;
  31. explicit SubDirectory(const SubDirectory& other) = delete;
  32. SubDirectory& operator =(const SubDirectory &other) = delete;
  33. SubDirectory(long long offset, DatFile &dat, long long max_subdirs = 63);
  34. ~SubDirectory();
  35. void MakeDictionary(std::map<long long, std::shared_ptr<SubFile>> &dict);
  36. bool MakeSubDirectories();
  37. bool MakeSubFiles();
  38. static std::unordered_set<long long> visited_subdirectories_;
  39. static std::unordered_set<long long> visited_subfiles_;
  40. static std::set<std::shared_ptr<SubDirectory>, SubDirectoryOffsetComp> subdir_init_queue_;
  41. static std::set<std::shared_ptr<SubDirectory>, SubDirectoryOffsetComp> subfile_init_queue_;
  42. private:
  43. std::shared_ptr<SubFile> MakeSubfile(long long dictionary_offset, long long unknown1, long long file_id, long long file_offset,
  44. long long file_size, long long timestamp, long long version, long long block_size, long long unknown2);
  45. FILE_TYPE GetSubfileType(long long file_id, long long file_offset) const;
  46. DatFile &dat_;
  47. long long offset_;
  48. long long max_subdirs_;
  49. std::vector<std::shared_ptr<SubDirectory>> subdirs_;
  50. std::vector<std::shared_ptr<SubFile>> subfiles_;
  51. };
  52. }
  53. };
  54. #endif //LOTRO_DAT_PATCHER_SUBDIRECTORY_H