Skip to content

Commit

Permalink
fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
fiso64 committed Oct 12, 2024
1 parent 13f3cbf commit e74dc4b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
12 changes: 6 additions & 6 deletions slsk-batchdl/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ public void PostProcessArgs() // must be run after extracting tracklist

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");
Expand Down
5 changes: 4 additions & 1 deletion slsk-batchdl/M3uEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ public M3uEditor(string path, TrackLists trackLists, M3uOption option) : this(tr

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();
Expand Down
2 changes: 1 addition & 1 deletion slsk-batchdl/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async Task<bool> process(SlResponse response, SlFile file)
}
}

return (Path.GetFullPath(saveFilePath), chosenFile);
return (Utils.GetFullPath(saveFilePath), chosenFile);
}


Expand Down
11 changes: 11 additions & 0 deletions slsk-batchdl/Utilities/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public static void WriteAllLines(string path, IEnumerable<string> lines, char se
}
}

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);
Expand Down Expand Up @@ -620,6 +628,9 @@ public static string GreatestCommonDirectorySlsk(IEnumerable<string> paths)

public static string NormalizedPath(string path)
{
if (string.IsNullOrEmpty(path))
return path;

return path.Replace('\\', '/').TrimEnd('/').Trim();
}

Expand Down

0 comments on commit e74dc4b

Please sign in to comment.