forked from TestableIO/System.IO.Abstractions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMockUnixSupport.cs
32 lines (27 loc) · 869 Bytes
/
MockUnixSupport.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Text.RegularExpressions;
namespace System.IO.Abstractions.TestingHelpers
{
internal static class MockUnixSupport
{
internal static string Path(string path, Func<bool> isUnixF = null)
{
var isUnix = isUnixF ?? IsUnixPlatform;
if (isUnix())
{
path = Regex.Replace(path, @"^[a-zA-Z]:(?<path>.*)$", "${path}");
path = path.Replace(@"\", "/");
}
return path;
}
internal static string Separator(Func<bool> isUnixF = null)
{
var isUnix = isUnixF ?? IsUnixPlatform;
return isUnix() ? "/" : @"\";
}
internal static bool IsUnixPlatform()
{
int p = (int)Environment.OSVersion.Platform;
return (p == 4) || (p == 6) || (p == 128);
}
}
}