Merge pull request #8370 from orezraey/fix/pad-test-unicode-config-path

test(pad): set the input mapping path through the wide environment on Windows
This commit is contained in:
Dean authored and GitHub committed 2026-10-23 11:28:44 +13:00
commit f57ceaad6b
1 file changed
+9 -13
@@ -18,6 +18,14 @@ void require(bool condition, const char* message) {
std::filesystem::path root;
void setConfigPath(const std::filesystem::path& path) {
#ifdef _WIN32
require(_wputenv_s(L"ANYPS5_INPUT_CONFIG", path.wstring().c_str()) == 0, "set ANYPS5_INPUT_CONFIG");
#else
require(::setenv("ANYPS5_INPUT_CONFIG", path.string().c_str(), 1) == 0, "set ANYPS5_INPUT_CONFIG");
#endif
}
void useConfig(const std::string& text) {
const auto path = root / "anyps5-input.ini";
{
@@ -25,11 +33,7 @@ void useConfig(const std::string& text) {
file << text;
require(file.good(), "write the input mapping");
}
#ifdef _WIN32
require(_putenv_s("ANYPS5_INPUT_CONFIG", path.string().c_str()) == 0, "set ANYPS5_INPUT_CONFIG");
#else
require(::setenv("ANYPS5_INPUT_CONFIG", path.string().c_str(), 1) == 0, "set ANYPS5_INPUT_CONFIG");
#endif
setConfigPath(path);
}
bool rejects(const std::string& text) {
@@ -140,14 +144,6 @@ void mouseLookReject() {
require(rejects("MouseDecayMs = 20\nmousedecayms = 30\n"), "a mouse setting given twice is rejected");
}
void setConfigPath(const std::filesystem::path& path) {
#ifdef _WIN32
require(_wputenv_s(L"ANYPS5_INPUT_CONFIG", path.wstring().c_str()) == 0, "set ANYPS5_INPUT_CONFIG");
#else
require(::setenv("ANYPS5_INPUT_CONFIG", path.string().c_str(), 1) == 0, "set ANYPS5_INPUT_CONFIG");
#endif
}
void nonAsciiPaths() {
const std::u8string name = u8"anyps5-input-\u00fc-\u65e5\u672c-" + std::u8string(root.filename().u8string());
const auto directory = root / std::filesystem::path(name);