#pragma once #undef _DLL #include #include #include #include #include #include #include "Resource.h" #include "StormLib.h" namespace Ship { class File; class Archive : public std::enable_shared_from_this { public: Archive(const std::string& MainPath, bool enableWriting); Archive(const std::string& MainPath, const std::string& PatchesPath, bool enableWriting, bool genCRCMap = true); ~Archive(); bool IsMainMPQValid(); static std::shared_ptr CreateArchive(const std::string& archivePath, int fileCapacity); std::shared_ptr LoadFile(const std::string& filePath, bool includeParent = true, std::shared_ptr FileToLoad = nullptr); std::shared_ptr LoadPatchFile(const std::string& filePath, bool includeParent = true, std::shared_ptr FileToLoad = nullptr); bool AddFile(const std::string& path, uintptr_t fileData, DWORD dwFileSize); bool RemoveFile(const std::string& path); bool RenameFile(const std::string& oldPath, const std::string& newPath); std::vector ListFiles(const std::string& searchMask) const; bool HasFile(const std::string& searchMask) const; const std::string* HashToString(uint64_t hash) const; protected: bool Load(bool enableWriting, bool genCRCMap); bool Unload(); private: std::string MainPath; std::string PatchesPath; std::map mpqHandles; std::vector addedFiles; std::unordered_map hashes; HANDLE mainMPQ; bool LoadMainMPQ(bool enableWriting, bool genCRCMap); bool LoadPatchMPQs(); bool LoadPatchMPQ(const std::string& path); }; }