Files
admin aa59132330 Rewrite Update module and update client/server sources
Update: drop Qt dependency, rewrite as pure Win32 using v142 toolset. Replace Update.ui/qrc and miniz-based Zip with Api/Crypto/Http/Json/Unzip/UpdateWindow modules.

CrownClient/CrownServer: update Verify and main sources, retarget x64 configs to v142 (VS2019) with SDK 10.0.19041.0, fix VMProtect SDK paths.
2026-10-17 16:31:54 +08:00

55 lines
1.6 KiB
C++

#pragma once
#include <functional>
#include <string>
#include <vector>
namespace updater {
// 基于 miniz 的只读解压封装:支持 UTF-8/GBK 条目名、Zip Slip 防护、进度回调
class Unzip {
public:
struct Entry {
std::wstring name; // 解码后的相对路径
unsigned long long size = 0; // 解压后大小
bool directory = false;
};
// 返回 false 表示中止解压
using ProgressFunc = std::function<bool(unsigned long long done,
unsigned long long total,
const std::wstring& currentName)>;
Unzip();
~Unzip();
Unzip(const Unzip&) = delete;
Unzip& operator=(const Unzip&) = delete;
bool Open(const std::wstring& zipPath, std::wstring& err);
void Close();
bool opened() const { return opened_; }
unsigned int EntryCount() const;
bool EntryAt(unsigned int index, Entry& out) const;
// 判断包内是否所有条目都位于同一个顶层目录下
bool DetectCommonRoot(std::wstring& root) const;
// 解压全部条目到 targetDir
// stripRoot=true 时去掉公共顶层目录
// writtenFiles 返回实际写入的文件绝对路径
bool ExtractAll(const std::wstring& targetDir,
bool stripRoot,
ProgressFunc progress,
std::vector<std::wstring>& writtenFiles,
std::wstring& err);
private:
struct Archive;
Archive* archive_ = nullptr;
bool opened_ = false;
};
}