#pragma once #include #include #include #include #include #include class PatchFileIndex { public: static constexpr size_t CHUNK_SIZE = 0x6000; explicit PatchFileIndex(const std::string& root_dir); struct File { PatchFileIndex* index; std::vector path_directories; std::string name; std::shared_ptr loaded_data; std::vector chunk_crcs; uint32_t crc32; uint32_t size; explicit File(PatchFileIndex* index); std::shared_ptr load_data(); }; const std::vector>& all_files() const; std::shared_ptr get(const std::string& filename) const; private: std::vector> files_by_patch_order; std::unordered_map> files_by_name; std::string root_dir; }; struct PatchFileChecksumRequest { std::shared_ptr file; uint32_t crc32; uint32_t size; bool response_received; explicit PatchFileChecksumRequest(std::shared_ptr file) : file(file), crc32(0), size(0), response_received(false) {} inline bool needs_update() const { return !this->response_received || (this->crc32 != this->file->crc32) || (this->size != this->file->size); } };