#include "zip.h" #include #include #include #include #include "str_util.h" struct CaseInsensitiveHash { size_t operator()(const std::string& str) const { // 创建字符串的小写副本 std::string lowercaseStr = str_util::tolower(str); // 对小写字符串使用标准哈希函数 return std::hash{}(lowercaseStr); } }; // 比较函数,忽略大小写 struct CaseInsensitiveEqual { bool operator()(const std::string& left, const std::string& right) const { return left.size() == right.size() && std::equal(left.begin(), left.end(), right.begin(), [](unsigned char a, unsigned char b) { return std::tolower(a) == std::tolower(b); }); } }; class VFS { public: VFS(); ~VFS(); bool AddArchive(std::string path); bool AddArchiveFromResource(HMODULE hModule, int resourceID); void AddArchiveWithErrorMsg(std::string path); void AddArchiveFromResourceWithErrorMsg(HMODULE hModule, int resourceID); bool ContainsFile(std::string path); bool ContainsFile(std::wstring path); bool ContainsHandle(HANDLE hFile); HANDLE CreateFileW(std::wstring path); bool ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead); void CloseHandle(HANDLE hFile); BOOL GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation); DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize); DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod); BOOL SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod); std::unordered_map files; std::string GetBasePath(); private: std::string base_path; std::list archives; std::unordered_map handles; };