#pragma once #include #include #include #include #include struct ResourceEntry { std::string filename; uint64_t offset; uint64_t size; uint32_t checksum; }; class ResourcePack { public: ResourcePack(); ~ResourcePack(); auto loadPack(const std::string& pack_file) -> bool; auto savePack(const std::string& pack_file) -> bool; auto addFile(const std::string& filename, const std::string& filepath) -> bool; auto addDirectory(const std::string& directory) -> bool; auto getResource(const std::string& filename) -> std::vector; auto hasResource(const std::string& filename) const -> bool; void clear(); auto getResourceCount() const -> size_t; auto getResourceList() const -> std::vector; static const std::string DEFAULT_ENCRYPT_KEY; private: static auto calculateChecksum(const std::vector& data) -> uint32_t; static void encryptData(std::vector& data, const std::string& key); static void decryptData(std::vector& data, const std::string& key); std::unordered_map resources_; std::vector data_; bool loaded_{false}; };