Files
crown/Update/Utils.h
T
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

50 lines
1.8 KiB
C++

#pragma once
#include <windows.h>
#include <string>
#include <vector>
namespace updater {
class Utils {
public:
static std::wstring Utf8ToWide(const std::string& s);
static std::string WideToUtf8(const std::wstring& s);
static std::wstring CodePageToWide(const std::string& s, UINT codePage);
static bool IsValidUtf8(const std::string& s);
static std::wstring DecodeEntryName(const std::string& raw);
static std::wstring GetModuleDir();
static std::wstring GetTempDir();
static std::wstring JoinPath(const std::wstring& dir, const std::wstring& rel);
static std::wstring GetParentDir(const std::wstring& path);
static std::wstring Trim(const std::wstring& s);
static std::wstring NormalizeSlashes(std::wstring path);
static bool CreateDirRecursive(const std::wstring& dir);
static bool FileExists(const std::wstring& path);
static bool DirExists(const std::wstring& path);
static bool DeleteFileForce(const std::wstring& path);
static std::wstring MakeUniqueTempFile(const std::wstring& dir, const std::wstring& prefix);
static std::wstring FormatSize(unsigned long long bytes);
static std::wstring FormatSpeed(unsigned long long bytesPerSec);
static std::string Sha256Hex(const void* data, size_t size);
static std::string Sha256HexFile(const std::wstring& path);
static std::string ToLowerAscii(const std::string& s);
static std::wstring UrlEncode(const std::wstring& s);
static bool IsAbsoluteUrl(const std::wstring& url);
static bool LaunchProcess(const std::wstring& exe,
const std::wstring& args,
const std::wstring& workDir);
static bool WaitForProcessExit(const std::wstring& processName, int timeoutSec);
static bool ReplaceInUse(const std::wstring& srcTmp, const std::wstring& target);
};
}