diff --git a/slsk-batchdl/Config.cs b/slsk-batchdl/Config.cs index 0e41244..f1df348 100644 --- a/slsk-batchdl/Config.cs +++ b/slsk-batchdl/Config.cs @@ -245,12 +245,12 @@ public class Config nameFormat = nameFormat.Trim(); - confPath = Path.GetFullPath(Utils.ExpandUser(confPath)); - parentDir = Path.GetFullPath(Utils.ExpandUser(parentDir)); - m3uFilePath = Path.GetFullPath(Utils.ExpandUser(m3uFilePath)); - indexFilePath = Path.GetFullPath(Utils.ExpandUser(indexFilePath)); - skipMusicDir = Path.GetFullPath(Utils.ExpandUser(skipMusicDir)); - failedAlbumPath = Path.GetFullPath(Utils.ExpandUser(failedAlbumPath)); + confPath = Utils.GetFullPath(Utils.ExpandUser(confPath)); + parentDir = Utils.GetFullPath(Utils.ExpandUser(parentDir)); + m3uFilePath = Utils.GetFullPath(Utils.ExpandUser(m3uFilePath)); + indexFilePath = Utils.GetFullPath(Utils.ExpandUser(indexFilePath)); + skipMusicDir = Utils.GetFullPath(Utils.ExpandUser(skipMusicDir)); + failedAlbumPath = Utils.GetFullPath(Utils.ExpandUser(failedAlbumPath)); if (failedAlbumPath.Length == 0) failedAlbumPath = Path.Join(parentDir, "failed"); diff --git a/slsk-batchdl/M3uEditor.cs b/slsk-batchdl/M3uEditor.cs index 886a40b..933b2c8 100644 --- a/slsk-batchdl/M3uEditor.cs +++ b/slsk-batchdl/M3uEditor.cs @@ -32,10 +32,13 @@ public class M3uEditor // todo: separate into M3uEditor and IndexEditor public void SetPathAndLoad(string path) { + if (string.IsNullOrEmpty(path)) + return; + if (this.path != null && Utils.NormalizedPath(this.path) == Utils.NormalizedPath(path)) return; - this.path = Path.GetFullPath(path); + this.path = Utils.GetFullPath(path); parent = Utils.NormalizedPath(Path.GetDirectoryName(this.path)); lines = ReadAllLines().ToList(); diff --git a/slsk-batchdl/Search.cs b/slsk-batchdl/Search.cs index 3e1eaa1..605d205 100644 --- a/slsk-batchdl/Search.cs +++ b/slsk-batchdl/Search.cs @@ -256,7 +256,7 @@ static class Search } } - return (Path.GetFullPath(saveFilePath), chosenFile); + return (Utils.GetFullPath(saveFilePath), chosenFile); } diff --git a/slsk-batchdl/Utilities/Utils.cs b/slsk-batchdl/Utilities/Utils.cs index 24adda2..c8ff60b 100644 --- a/slsk-batchdl/Utilities/Utils.cs +++ b/slsk-batchdl/Utilities/Utils.cs @@ -58,6 +58,14 @@ public static class Utils } } + public static string GetFullPath(string path) + { + if (string.IsNullOrEmpty(path)) + return path; + + return Path.GetFullPath(path); + } + public static string GetAsPathSlsk(string fname) { return fname.Replace('\\', Path.DirectorySeparatorChar); @@ -620,6 +628,9 @@ public static class Utils public static string NormalizedPath(string path) { + if (string.IsNullOrEmpty(path)) + return path; + return path.Replace('\\', '/').TrimEnd('/').Trim(); }