You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/Recyclarr.TestLibrary/FileUtils.cs

25 lines
681 B

using System.Text.RegularExpressions;
namespace Recyclarr.TestLibrary;
public static partial class FileUtils
{
public static ICollection<string> NormalizePaths(IEnumerable<string> paths)
{
return paths.Select(NormalizePath).ToList();
}
public static string NormalizePath(string path)
{
return MockUnixSupport.IsUnixPlatform()
? WindowsRootRegex().Replace(path, "/").Replace("\\", "/")
: LinuxRootRegex().Replace(path, @"C:\").Replace("/", "\\");
}
[GeneratedRegex(@"^C:\\")]
private static partial Regex WindowsRootRegex();
[GeneratedRegex("^/")]
private static partial Regex LinuxRootRegex();
}