Add IPlatformIdentifier.NormalizePath

This commit is contained in:
Jordan Dominion
2024-07-26 17:04:02 -04:00
parent 25776270c3
commit 17712f682d
2 changed files with 19 additions and 1 deletions
@@ -17,5 +17,12 @@ namespace Tgstation.Server.Host.System
/// The extension of executable script files for the system.
/// </summary>
string ScriptFileExtension { get; }
/// <summary>
/// Normalize a path for consistency.
/// </summary>
/// <param name="path">The path to normalize.</param>
/// <returns>The normalized path.</returns>
string NormalizePath(string path);
}
}
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
namespace Tgstation.Server.Host.System
@@ -21,5 +22,15 @@ namespace Tgstation.Server.Host.System
IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ScriptFileExtension = IsWindows ? "bat" : "sh";
}
/// <inheritdoc />
public string NormalizePath(string path)
{
ArgumentNullException.ThrowIfNull(path);
if (IsWindows)
path = path.Replace('\\', '/');
return path;
}
}
}