From 35cc54c54078d251806f1d13b1f7ab36855bce1b Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 2 Apr 2024 22:44:36 -0400 Subject: [PATCH] Change user dir on Windows to AppData/Local/Rack2. --- src/asset.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/asset.cpp b/src/asset.cpp index fbb01e2d..eab8f2a7 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -108,15 +108,23 @@ static void initUserDir() { std::string oldUserDir; #if defined ARCH_WIN - // Get "My Documents" path - wchar_t documentsBufW[MAX_PATH] = L"."; - HRESULT result = SHGetFolderPathW(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, documentsBufW); - assert(result == S_OK); + // Get AppData/Local path + WCHAR localBufW[MAX_PATH] = {}; + HRESULT localH = SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, localBufW); + assert(SUCCEEDED(localH)); + std::string localDir = string::UTF16toUTF8(localBufW); - // Rack <2.5.0 used "My Documents/Rack2" - oldUserDir = system::join(string::UTF16toUTF8(documentsBufW), "Rack" + APP_VERSION_MAJOR); + // Usually C:/Users//AppData/Local/Rack2 + userDir = system::join(localDir, "Rack" + APP_VERSION_MAJOR); + + // Get Documents path + WCHAR documentsBufW[MAX_PATH] = {}; + HRESULT documentsH = SHGetFolderPathW(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, documentsBufW); + assert(SUCCEEDED(documentsH)); + std::string documentsDir = string::UTF16toUTF8(documentsBufW); - // TODO new userDir + // Rack <2.5.0 used "My Documents/Rack2" + oldUserDir = system::join(documentsDir, "Rack" + APP_VERSION_MAJOR); #endif #if defined ARCH_MAC