aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Common/CommonExtensions.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-06-07 14:45:04 -0500
committerGitHub <noreply@github.com>2026-06-07 14:45:04 -0500
commitb747b68ba0ba777be578e73bd1328fbde940e436 (patch)
tree160d23aeb8707dc04f81bb52e81913c1b77bb2a4 /src/slskd/Common/CommonExtensions.cs
parente06999e5eec1616d93b34ffbab0eade617d1aaf6 (diff)
parent2d069bbf1f71f38e1286e27d45c24b478feb11ac (diff)
downloadslskd-b747b68ba0ba777be578e73bd1328fbde940e436.tar.gz
Merge branch 'master' into dependabot/npm_and_yarn/src/web/launch-editor-2.14.1
Diffstat (limited to 'src/slskd/Common/CommonExtensions.cs')
-rw-r--r--src/slskd/Common/CommonExtensions.cs74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs
index 5ff3e519..95721163 100644
--- a/src/slskd/Common/CommonExtensions.cs
+++ b/src/slskd/Common/CommonExtensions.cs
@@ -382,21 +382,6 @@ namespace slskd
.Deserialize<T>(str);
/// <summary>
- /// Converts a fully qualified remote filename to a local filename based in the provided
- /// <paramref name="baseDirectory"/>, swapping directory characters for those specific to the local OS, removing any
- /// characters that are invalid for the local OS, and making the path relative to the remote store (including the
- /// filename and the parent folder).
- /// </summary>
- /// <param name="remoteFilename">The fully qualified remote filename to convert.</param>
- /// <param name="baseDirectory">The base directory for the local filename.</param>
- /// <returns>The converted filename.</returns>
- [Obsolete("Find something more intelligent to do instead of this")]
- public static string ToLocalFilename(this string remoteFilename, string baseDirectory)
- {
- return FileSafety.CombineSafely(baseDirectory, remoteFilename.ToLocalRelativeFilename());
- }
-
- /// <summary>
/// Converts the given path to the normalized format (normalizes path separators to backslashes).
/// </summary>
/// <remarks>
@@ -410,16 +395,6 @@ namespace slskd
}
/// <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);
- }
-
- /// <summary>
/// <see cref="Path.GetDirectoryName(string)"/>, but for paths normalized to use backslashes.
/// </summary>
/// <param name="path"></param>
@@ -440,55 +415,6 @@ namespace slskd
}
/// <summary>
- /// Converts a fully qualified remote filename to a local filename, swapping directory characters for those specific
- /// to the local OS, removing any characters that are invalid for the local OS, and making the path relative to the
- /// remote store (including the filename and the parent folder).
- /// </summary>
- /// <param name="remoteFilename">The fully qualified remote filename to convert.</param>
- /// <returns>The converted filename.</returns>
- [Obsolete("Find something more intelligent to do instead of this")]
- public static string ToLocalRelativeFilename(this string remoteFilename)
- {
- if (string.IsNullOrWhiteSpace(remoteFilename))
- {
- throw new ArgumentException($"Invalid remote filename; expected a non-whitespace value, received '{remoteFilename}'", nameof(remoteFilename));
- }
-
- // normalize path separators
- var localizedRemoteFilename = remoteFilename.LocalizePath();
-
- var parts = localizedRemoteFilename.Split(Path.DirectorySeparatorChar);
-
- if (parts.Length == 1)
- {
- return parts.First().ReplaceInvalidFileNameCharacters();
- }
-
- var file = parts.Last().ReplaceInvalidFileNameCharacters();
- var directory = parts.Reverse().Skip(1).Take(1).Single().ReplaceInvalidFileNameCharacters();
-
- return FileSafety.CombineSafely(directory, file);
- }
-
- /// <summary>
- /// Replaces any occurrence of an invalid filename character with the specified <see paramref="replacement"/>.
- /// </summary>
- /// <param name="path">The path to sanitize.</param>
- /// <param name="replacement">The character with which to replace invalid characters.</param>
- /// <returns>The sanitized path.</returns>
- public static string ReplaceInvalidFileNameCharacters(this string path, char replacement = '_')
- {
- var sanitized = path;
-
- foreach (var c in Path.GetInvalidFileNameChars())
- {
- sanitized = sanitized.Replace(c, replacement);
- }
-
- return sanitized;
- }
-
- /// <summary>
/// Converts a ModelStateDictionary into a human-readable format.
/// </summary>
/// <param name="dictionary">The ModelStateDictionary to format.</param>