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