diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-09-03 16:16:58 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-03 16:16:58 -0500 |
| commit | 05ce3650a2afbfbc08c3903dccdec4a3526a3cd1 (patch) | |
| tree | be55213e82c9325e94b8e95f33e934e03c4512c9 /src/slskd/Common | |
| parent | 94d16f28dfc0228febc803fffd154357bd452a0f (diff) | |
| parent | 09345a8c1c1cf3f2bf29604d8653a68cc8b8c911 (diff) | |
| download | slskd-05ce3650a2afbfbc08c3903dccdec4a3526a3cd1.tar.gz | |
Merge pull request #627 from slskd/slashes
Normalize file path separators to backslashes
Diffstat (limited to 'src/slskd/Common')
| -rw-r--r-- | src/slskd/Common/CommonExtensions.cs | 16 |
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); |
