mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 04:57:17 +01:00
Add IPlatformIdentifier.NormalizePath
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user