mirror of
https://gitea.tendokyu.moe/moegrid/sega-mount.git
synced 2026-10-11 16:58:08 +03:00
33 lines
1.0 KiB
C++
33 lines
1.0 KiB
C++
#pragma once
|
||
|
||
#include <string>
|
||
#include <cstdint>
|
||
#include <windows.h>
|
||
|
||
namespace utils {
|
||
// 将NTSTATUS转换为0x%08X格式的字符串
|
||
std::string ntstatus_str(NTSTATUS status);
|
||
|
||
// 将十六进制字符串转换为字节数组
|
||
bool hex_to_bytes(const std::string &hex, uint8_t *out, size_t len);
|
||
|
||
// 规范化路径:将/转换为\,不翻倍反斜杠
|
||
std::wstring normalize_path(const std::wstring &path);
|
||
|
||
// 将wstring转为string
|
||
std::string wstr_to_str(const std::wstring &ws);
|
||
|
||
// 将UTF-8 char*字符串转为wstring
|
||
std::wstring to_wstring(const char *s);
|
||
|
||
// 将string转为wstring(UTF-8)
|
||
std::wstring to_wstring(const std::string &s);
|
||
|
||
// 将字节数组格式化为十六进制小写字符串
|
||
std::string bytes_to_hex(const uint8_t *data, size_t len);
|
||
|
||
// 将 Windows GetLastError() 的错误码转为可读字符串
|
||
// 格式: "5 (ERROR_ACCESS_DENIED)" — 数字 + 符号名
|
||
std::string last_error_str(DWORD code = GetLastError());
|
||
}
|