diff options
author | [email protected] <sr55> | 2016-01-29 21:21:07 +0000 |
---|---|---|
committer | [email protected] <sr55> | 2016-01-29 21:21:07 +0000 |
commit | 8343b1cacf87f673a7e0b82c6cd1449d9c529edc (patch) | |
tree | d953661f4cecf1d7bf2e5f8f00a1767ce40d72e7 /win/CS/HandBrakeWPF/Services/UserSettingService.cs | |
parent | db29f87dc3bf3909d263491390d0f56418616e26 (diff) |
WinGui: Allow the Nightly build and Release version to be run side-by-side. The nightly build will store the config and presets file in a "Nightly" sub directory. If this directory doesn't exist, it'll create it and try port the release versions to it.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/UserSettingService.cs')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/UserSettingService.cs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/Services/UserSettingService.cs b/win/CS/HandBrakeWPF/Services/UserSettingService.cs index 612999a3a..acff3209a 100644 --- a/win/CS/HandBrakeWPF/Services/UserSettingService.cs +++ b/win/CS/HandBrakeWPF/Services/UserSettingService.cs @@ -15,8 +15,11 @@ namespace HandBrakeWPF.Services using System.Reflection;
using System.Xml.Serialization;
+ using HandBrake.ApplicationServices.Utilities;
+
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.Utilities;
using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
using SettingChangedEventArgs = HandBrakeWPF.EventArgs.SettingChangedEventArgs;
@@ -29,7 +32,7 @@ namespace HandBrakeWPF.Services /// <summary>
/// The Settings File
/// </summary>
- private readonly string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml";
+ private readonly string settingsFile = Path.Combine(DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly()), "settings.xml");
/// <summary>
/// The XML Serializer
@@ -151,6 +154,24 @@ namespace HandBrakeWPF.Services this.userSettings = data;
}
}
+ else if (VersionHelper.IsNightly() && File.Exists(Path.Combine(DirectoryUtilities.GetUserStoragePath(false), "settings.xml")))
+ {
+ // Port the release versions config to the nightly.
+ string releasePresetFile = Path.Combine(DirectoryUtilities.GetUserStoragePath(false), "settings.xml");
+
+ if (!Directory.Exists(DirectoryUtilities.GetUserStoragePath(true)))
+ {
+ Directory.CreateDirectory(DirectoryUtilities.GetUserStoragePath(true));
+ }
+
+ File.Copy(releasePresetFile, Path.Combine(DirectoryUtilities.GetUserStoragePath(true), "settings.xml"));
+
+ using (StreamReader reader = new StreamReader(this.settingsFile))
+ {
+ Collections.SerializableDictionary<string, object> data = (Collections.SerializableDictionary<string, object>)this.serializer.Deserialize(reader);
+ this.userSettings = data;
+ }
+ }
else
{
this.userSettings = new Collections.SerializableDictionary<string, object>();
|