From 97ca89794688920b583ac5419ad82da8b8e469c6 Mon Sep 17 00:00:00 2001 From: fxliang Date: Fri, 19 Jan 2024 12:39:02 +0800 Subject: [PATCH] change method weasel_shared_data_dir --- RimeWithWeasel/WeaselUtility.cpp | 6 +----- WeaselDeployer/Configurator.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/RimeWithWeasel/WeaselUtility.cpp b/RimeWithWeasel/WeaselUtility.cpp index 53b60091f..b0887373d 100644 --- a/RimeWithWeasel/WeaselUtility.cpp +++ b/RimeWithWeasel/WeaselUtility.cpp @@ -28,11 +28,7 @@ const char* weasel_shared_data_dir() { GetModuleFileNameA(NULL, path, _countof(path)); std::string str_path(path); size_t k = str_path.find_last_of("/\\"); -#ifdef _WIN64 - strcpy_s(path + k - 3 , _countof(path) - (k + 3), "data"); -#else - strcpy_s(path + k + 1, _countof(path) - (k + 1), "data"); -#endif + strcpy_s(path + k + 1, _countof(path) - (k + 1), "data"); return path; } diff --git a/WeaselDeployer/Configurator.cpp b/WeaselDeployer/Configurator.cpp index 0962fb123..445bfd285 100644 --- a/WeaselDeployer/Configurator.cpp +++ b/WeaselDeployer/Configurator.cpp @@ -14,6 +14,7 @@ #include #pragma warning(default: 4005) #include +#include #include "WeaselDeployer.h" static void CreateFileIfNotExist(std::string filename) @@ -35,7 +36,12 @@ Configurator::Configurator() void Configurator::Initialize() { RIME_STRUCT(RimeTraits, weasel_traits); - weasel_traits.shared_data_dir = weasel_shared_data_dir(); + std::string shared_data_dir = weasel_shared_data_dir(); +#ifdef _WIN64 + shared_data_dir = std::regex_replace(shared_data_dir, std::regex("\\\\x64"), ""); +#endif + logn(shared_data_dir); + weasel_traits.shared_data_dir = shared_data_dir.c_str(); weasel_traits.user_data_dir = weasel_user_data_dir(); weasel_traits.prebuilt_data_dir = weasel_traits.shared_data_dir; const int len = 20;