diff --git a/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs b/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs index 805b93b97d..b22173d2c6 100644 --- a/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs +++ b/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs @@ -17,5 +17,12 @@ namespace Tgstation.Server.Host.System /// The extension of executable script files for the system. /// string ScriptFileExtension { get; } + + /// + /// Normalize a path for consistency. + /// + /// The path to normalize. + /// The normalized path. + string NormalizePath(string path); } } diff --git a/src/Tgstation.Server.Host/System/PlatformIdentifier.cs b/src/Tgstation.Server.Host/System/PlatformIdentifier.cs index 22931b97ce..afa9d607e1 100644 --- a/src/Tgstation.Server.Host/System/PlatformIdentifier.cs +++ b/src/Tgstation.Server.Host/System/PlatformIdentifier.cs @@ -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"; } + + /// + public string NormalizePath(string path) + { + ArgumentNullException.ThrowIfNull(path); + if (IsWindows) + path = path.Replace('\\', '/'); + + return path; + } } }