From b1bcee461fbb8473e7c8651e336a0419d3607d4f Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 7 Jul 2015 10:34:47 +0200 Subject: [PATCH] On Windows, store the config in the roaming APPDATA directory This avoids the "can't open user configuration file" error when running jd-gui from PROGRAMFILES with UAC enabled, as the un-elevated jd-gui process cannot write to that directory. --- .../ConfigurationXmlPersisterProvider.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/groovy/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.groovy b/app/src/main/groovy/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.groovy index a679b31d..6c5b5d79 100644 --- a/app/src/main/groovy/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.groovy +++ b/app/src/main/groovy/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.groovy @@ -32,6 +32,15 @@ class ConfigurationXmlPersisterProvider implements ConfigurationPersister { if (userConfigFile.exists()) { return new File(userConfigFile, Constants.CONFIG_FILENAME) } + } else if (PlatformService.instance.isWindows) { + // See: http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx + def roamingConfigHome = System.getenv('APPDATA') + if (roamingConfigHome) { + def roamingConfigHomeFile = new File(roamingConfigHome) + if (roamingConfigHomeFile.exists()) { + return new File(roamingConfigHomeFile, Constants.CONFIG_FILENAME) + } + } } return new File(Constants.CONFIG_FILENAME)