aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Common/CommonExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Common/CommonExtensions.cs')
-rw-r--r--src/slskd/Common/CommonExtensions.cs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs
index 65949016..6f39d17f 100644
--- a/src/slskd/Common/CommonExtensions.cs
+++ b/src/slskd/Common/CommonExtensions.cs
@@ -254,11 +254,21 @@ namespace slskd
}
/// <summary>
- /// Converts the given path to the local format (normalizes path separators).
+ /// Converts the given path to the normalized format (normalizes path separators to backslashes).
/// </summary>
/// <param name="path">The path to convert.</param>
/// <returns>The converted path.</returns>
- public static string ToLocalOSPath(this string path)
+ public static string NormalizePath(this string path)
+ {
+ return path.Replace('/', '\\');
+ }
+
+ /// <summary>
+ /// Converts the given path to the local format (normalizes path separators to Path.DirectorySeparatorChar).
+ /// </summary>
+ /// <param name="path">The path to convert.</param>
+ /// <returns>The converted path.</returns>
+ public static string LocalizePath(this string path)
{
return path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
}
@@ -278,7 +288,7 @@ namespace slskd
}
// normalize path separators
- var localizedRemoteFilename = remoteFilename.ToLocalOSPath();
+ var localizedRemoteFilename = remoteFilename.LocalizePath();
var parts = localizedRemoteFilename.Split(Path.DirectorySeparatorChar);