Refactor: replace C-style code with modern C++ idioms

This commit is contained in:
Changhua 2025-01-29 18:32:20 +08:00
parent 554d62efcf
commit 15267632a1

View File

@ -8,13 +8,13 @@
#include "exec_sql.h" #include "exec_sql.h"
#include "funcs.h" #include "funcs.h"
#include "log.hpp" #include "log.hpp"
#include "receive_msg.h"
#include "spy_types.h" #include "spy_types.h"
#include "util.h" #include "util.h"
using namespace std; using namespace std;
namespace fs = std::filesystem; namespace fs = std::filesystem;
extern bool gIsListeningPyq;
extern QWORD g_WeChatWinDllAddr; extern QWORD g_WeChatWinDllAddr;
#define HEADER_PNG1 0x89 #define HEADER_PNG1 0x89
@ -111,7 +111,6 @@ string DecryptImage(string src, string dir)
string dst = ""; string dst = "";
try {
if (dir.empty()) { if (dir.empty()) {
dst = fs::path(src).replace_extension(ext).string(); dst = fs::path(src).replace_extension(ext).string();
} else { } else {
@ -130,12 +129,6 @@ string DecryptImage(string src, string dir)
} }
replace(dst.begin(), dst.end(), '\\', '/'); replace(dst.begin(), dst.end(), '\\', '/');
} catch (const std::exception &e) {
LOG_ERROR(GB2312ToUtf8(e.what()));
} catch (...) {
LOG_ERROR("Unknow exception.");
return "";
}
ofstream out(dst.c_str(), ios::binary); ofstream out(dst.c_str(), ios::binary);
if (!out.is_open()) { if (!out.is_open()) {
@ -178,7 +171,8 @@ static int GetNextPage(QWORD id)
int RefreshPyq(QWORD id) int RefreshPyq(QWORD id)
{ {
if (!gIsListeningPyq) { auto &msgHandler = MessageHandler::getInstance();
if (!msgHandler.isPyqListening()) {
LOG_ERROR("没有启动朋友圈消息接收参考enable_receiving_msg"); LOG_ERROR("没有启动朋友圈消息接收参考enable_receiving_msg");
return -1; return -1;
} }
@ -332,7 +326,6 @@ string GetPCMAudio(uint64_t id, string dir, int32_t sr)
return pcmpath; return pcmpath;
} }
OcrResult_t GetOcrResult(string path) OcrResult_t GetOcrResult(string path)
{ {
OcrResult_t ret = { -1, "" }; OcrResult_t ret = { -1, "" };