From 286d6068478001d0671a65107ed3c4c4f8dc8546 Mon Sep 17 00:00:00 2001 From: lindeer Date: Wed, 30 Jul 2025 10:27:42 +0800 Subject: [PATCH] find config from env --- src/Config.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Config.cpp b/src/Config.cpp index 5c768c07c..901d93ccb 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -202,6 +202,16 @@ class ConfigInternal { } } + const char* envPath = std::getenv("OPENCC_SHARED_DIR"); + if (envPath != nullptr) { + std::string path(envPath); + path += '/' + fileName; + ifs.open(UTF8Util::GetPlatformString(path).c_str()); + if (ifs.is_open()) { + return path; + } + } + throw FileNotFound(fileName); } };