From 925dc6f6811dde2c80a1217e69c8a427f5003053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Feb 2024 19:46:17 +0800 Subject: [PATCH] TerminalFont (Windows): support portable Windows Terminal settings Fix #720 --- src/detection/terminalfont/terminalfont.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 532296af9..f48c37caf 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -170,7 +170,17 @@ static void detectFromWindowsTeriminal(const FFstrbuf* terminalExe, FFTerminalFo if(terminalExe && terminalExe->length > 0 && !ffStrbufEqualS(terminalExe, "Windows Terminal")) { char jsonPath[MAX_PATH + 1]; - if(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, jsonPath))) + strncpy(jsonPath, terminalExe->chars, ffStrbufLastIndexC(terminalExe, '\\') + 1); + char* pathEnd = jsonPath + strlen(jsonPath); + strncpy(pathEnd, ".portable", sizeof(jsonPath) - (size_t) (pathEnd - jsonPath) - 1); + + if(ffPathExists(jsonPath, FF_PATHTYPE_FILE)) + { + strncpy(pathEnd, "settings\\settings.json", sizeof(jsonPath) - (size_t) (pathEnd - jsonPath) - 1); + if(!ffAppendFileBuffer(jsonPath, &json)) + error = "Error reading Windows Terminal portable settings JSON file"; + } + else if(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, jsonPath))) { size_t remaining = sizeof(jsonPath) - strlen(jsonPath) - 1; if(ffStrbufContainIgnCaseS(terminalExe, "_8wekyb3d8bbwe\\"))