logic: fixed policy for finding windows user data folder (issue #612)

* creating "user_fallback" path in application directory if everything else fails
This commit is contained in:
mlangkabel
2018-08-24 10:50:00 +02:00
parent 50c0f6ef59
commit caad4dfc14
@@ -35,24 +35,40 @@ void setupApp(int argc, char *argv[])
{
appPath = appPath.substr(0, pos + 1);
}
AppPath::setAppPath(FilePath(appPath));
AppPath::setAppPath(FilePath(appPath));
}
{
FilePath userDataPath = AppPath::getAppPath().concatenate(L"user/");
if (!userDataPath.exists())
{
userDataPath = FilePath(std::string(std::getenv("APPDATA")) + "/../local/Coati Software/");
if (utility::getApplicationArchitectureType() == APPLICATION_ARCHITECTURE_X86_64)
FilePath userLocalPath = FilePath(std::string(std::getenv("LOCALAPPDATA")));
if (!userLocalPath.exists())
{
userDataPath.concatenate(L"Sourcetrail 64-bit/");
userLocalPath = FilePath(std::string(std::getenv("APPDATA")) + "/../local");
}
if (userLocalPath.exists())
{
userDataPath = userLocalPath.getConcatenated(L"Coati Software/");
if (utility::getApplicationArchitectureType() == APPLICATION_ARCHITECTURE_X86_64)
{
userDataPath.concatenate(L"Sourcetrail 64-bit/");
}
else
{
userDataPath.concatenate(L"Sourcetrail/");
}
userDataPath.makeCanonical();
}
else
{
userDataPath.concatenate(L"Sourcetrail/");
userDataPath = AppPath::getAppPath().concatenate(L"user_fallback/");
LOG_ERROR(L"The \"%LOCALAPPDATA%\" path could not be found. Falling back to \"" + userDataPath.wstr() + L"\" to store settings data.");
FileSystem::createDirectory(userDataPath);
}
userDataPath.makeCanonical();
}
UserPaths::setUserDataPath(userDataPath);
}