aboutsummaryrefslogtreecommitdiff
path: root/src/filemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/filemanager.cpp')
-rw-r--r--src/filemanager.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/filemanager.cpp b/src/filemanager.cpp
index a5bb779c..33ce4492 100644
--- a/src/filemanager.cpp
+++ b/src/filemanager.cpp
@@ -1203,12 +1203,21 @@ const char *proj_context_get_user_writable_directory(PJ_CONTEXT *ctx,
if (ctx->user_writable_directory.empty()) {
std::string path;
#ifdef _WIN32
+#ifdef __MINGW32__
std::wstring wPath;
wPath.resize(MAX_PATH);
if (SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0,
&wPath[0]) == S_OK) {
wPath.resize(wcslen(wPath.data()));
path = NS_PROJ::WStringToUTF8(wPath);
+#else
+ wchar_t* wPath;
+ if (SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &wPath) == S_OK){
+ std::wstring ws(wPath);
+ std::string str = NS_PROJ::WStringToUTF8(ws);
+ path = str;
+ CoTaskMemFree(wPath);
+#endif
} else {
const char *local_app_data = getenv("LOCALAPPDATA");
if (!local_app_data) {