1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 14:32:40 +00:00

fix paths

This commit is contained in:
fiso64 2024-10-12 13:07:49 +02:00
parent 13f3cbff47
commit e74dc4beda
4 changed files with 22 additions and 8 deletions

View file

@ -245,12 +245,12 @@ public class Config
nameFormat = nameFormat.Trim(); nameFormat = nameFormat.Trim();
confPath = Path.GetFullPath(Utils.ExpandUser(confPath)); confPath = Utils.GetFullPath(Utils.ExpandUser(confPath));
parentDir = Path.GetFullPath(Utils.ExpandUser(parentDir)); parentDir = Utils.GetFullPath(Utils.ExpandUser(parentDir));
m3uFilePath = Path.GetFullPath(Utils.ExpandUser(m3uFilePath)); m3uFilePath = Utils.GetFullPath(Utils.ExpandUser(m3uFilePath));
indexFilePath = Path.GetFullPath(Utils.ExpandUser(indexFilePath)); indexFilePath = Utils.GetFullPath(Utils.ExpandUser(indexFilePath));
skipMusicDir = Path.GetFullPath(Utils.ExpandUser(skipMusicDir)); skipMusicDir = Utils.GetFullPath(Utils.ExpandUser(skipMusicDir));
failedAlbumPath = Path.GetFullPath(Utils.ExpandUser(failedAlbumPath)); failedAlbumPath = Utils.GetFullPath(Utils.ExpandUser(failedAlbumPath));
if (failedAlbumPath.Length == 0) if (failedAlbumPath.Length == 0)
failedAlbumPath = Path.Join(parentDir, "failed"); failedAlbumPath = Path.Join(parentDir, "failed");

View file

@ -32,10 +32,13 @@ public class M3uEditor // todo: separate into M3uEditor and IndexEditor
public void SetPathAndLoad(string path) public void SetPathAndLoad(string path)
{ {
if (string.IsNullOrEmpty(path))
return;
if (this.path != null && Utils.NormalizedPath(this.path) == Utils.NormalizedPath(path)) if (this.path != null && Utils.NormalizedPath(this.path) == Utils.NormalizedPath(path))
return; return;
this.path = Path.GetFullPath(path); this.path = Utils.GetFullPath(path);
parent = Utils.NormalizedPath(Path.GetDirectoryName(this.path)); parent = Utils.NormalizedPath(Path.GetDirectoryName(this.path));
lines = ReadAllLines().ToList(); lines = ReadAllLines().ToList();

View file

@ -256,7 +256,7 @@ static class Search
} }
} }
return (Path.GetFullPath(saveFilePath), chosenFile); return (Utils.GetFullPath(saveFilePath), chosenFile);
} }

View file

@ -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) public static string GetAsPathSlsk(string fname)
{ {
return fname.Replace('\\', Path.DirectorySeparatorChar); return fname.Replace('\\', Path.DirectorySeparatorChar);
@ -620,6 +628,9 @@ public static class Utils
public static string NormalizedPath(string path) public static string NormalizedPath(string path)
{ {
if (string.IsNullOrEmpty(path))
return path;
return path.Replace('\\', '/').TrimEnd('/').Trim(); return path.Replace('\\', '/').TrimEnd('/').Trim();
} }