summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
author^x3ro <[email protected]>2019-12-23 17:28:45 +0100
committerScott <[email protected]>2020-02-07 23:16:53 +0000
commitcd1a7fe7233d731ab9b532a19dbb5eb49e5a7a8e (patch)
tree1f7e9c8a95577d6a85000787ac34589ea05ead73 /win/CS
parentb436ec04facbb390431738d37856e887fd2155e8 (diff)
Replace `/` in default path with windows compatible '\'
Windows usually uses a back-slash `\` as path separator. However, many applications (e.g. the Windows Explorer) also support using forward-slashes `/` and replace them with `\`. HandBrake did not do this and as a result, the path was broken when using e.g. `{source_path}/converted` as "Default Path". (See #2522) This commit fixes this issue by replacing `/` with `\` before further processing the path.
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs7
1 files changed, 4 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
index 3baab2e54..06c282700 100644
--- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
+++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
@@ -196,7 +196,8 @@ namespace HandBrakeWPF.Helpers
private static string GetAutonamePath(IUserSettingService userSettingService, EncodeTask task, string sourceName)
{
- string autoNamePath = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim();
+ string autoNamePath = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim()
+ .Replace("/", "\\");
// If enabled, use the current Destination path.
if (!userSettingService.GetUserSetting<bool>(UserSettingConstants.AlwaysUseDefaultPath) && !string.IsNullOrEmpty(task.Destination))
@@ -209,9 +210,9 @@ namespace HandBrakeWPF.Helpers
}
// Handle {source_path}
- if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") && !string.IsNullOrEmpty(task.Source))
+ if (autoNamePath.StartsWith("{source_path}") && !string.IsNullOrEmpty(task.Source))
{
- string savedPath = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().Replace("{source_path}\\", string.Empty).Replace("{source_path}", string.Empty);
+ string savedPath = autoNamePath.Replace("{source_path}\\", string.Empty).Replace("{source_path}", string.Empty);
string directory = Directory.Exists(task.Source) ? task.Source : Path.GetDirectoryName(task.Source);
autoNamePath = Path.Combine(directory, savedPath);
}