From 0d9e25c402dc119155e38e61a913c7ea9a0feff8 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Tue, 9 Jul 2019 19:32:01 -0400
Subject: [PATCH] fileutils: migrate windows files to local appdata

Change-Id: I3c334493e5f45a2c1d6398d396c2ad109a2f6a5d
---
 src/fileutils.cpp | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/fileutils.cpp b/src/fileutils.cpp
index a5e25066d0..6e433073ef 100644
--- a/src/fileutils.cpp
+++ b/src/fileutils.cpp
@@ -489,7 +489,6 @@ writeArchive(const std::string& archive_str, const std::string& path, const std:
     }
 }
 
-
 FileHandle::FileHandle(const std::string &n) : fd(-1), name(n)
 {}
 
@@ -623,6 +622,16 @@ get_data_dir(const char* pkg)
     return get_home_dir() + DIR_SEPARATOR_STR
             + "Library" + DIR_SEPARATOR_STR + "Application Support"
             + DIR_SEPARATOR_STR + pkg;
+#elif defined(_WIN32)
+    if (!strcmp(pkg, "ring")) {
+        return get_home_dir() + DIR_SEPARATOR_STR
+            + ".local" + DIR_SEPARATOR_STR
+            + "share" DIR_SEPARATOR_STR + pkg;
+    } else{
+        return get_home_dir() + DIR_SEPARATOR_STR
+            + "AppData" + DIR_SEPARATOR_STR + "Local"
+            + DIR_SEPARATOR_STR + pkg;
+    }
 #elif defined (RING_UWP)
     std::vector<std::string> paths;
     emitSignal<DRing::ConfigurationSignal::GetAppDataPath>("", &paths);
@@ -679,6 +688,16 @@ get_config_dir(const char* pkg)
     std::string configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR
         + "Library" + DIR_SEPARATOR_STR + "Application Support"
         + DIR_SEPARATOR_STR + pkg;
+#elif defined(_WIN32)
+    std::string configdir;
+    if (!strcmp(pkg, "ring")) {
+        configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR +
+                    ".config" + DIR_SEPARATOR_STR + pkg;
+    } else {
+        configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR +
+                    "AppData" + DIR_SEPARATOR_STR +
+                    "Local" + DIR_SEPARATOR_STR + pkg;
+    }
 #else
     std::string configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR +
                             ".config" + DIR_SEPARATOR_STR + pkg;
-- 
GitLab