Skip to content

Commit

Permalink
On Windows, store the config in the roaming APPDATA directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sschuberth committed Jul 7, 2015
1 parent 920dfbd commit b1bcee4
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b1bcee4

Please sign in to comment.