18 using System.Runtime.CompilerServices;
19 using System.Text.RegularExpressions;
28 public static readonly
string ReservedWordsPrefix =
Config.
Get(
"reserved-words-prefix",
"@");
29 private static readonly Regex ToValidWindowsPathRegex =
new Regex(
"((?<=(\\\\|/|^))(CON|PRN|AUX|NUL|(COM[0-9])|(LPT[0-9]))(?=(\\.|\\\\|/|$)))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
30 private static readonly
string _fixPathRegex = ReservedWordsPrefix +
"$&";
31 private static readonly
bool _isWindows =
OS.
IsWindows;
37 [MethodImpl(MethodImplOptions.AggressiveInlining)]
40 return _isWindows ? ToValidWindowsPathRegex.Replace(path, _fixPathRegex) : path;
47 [MethodImpl(MethodImplOptions.AggressiveInlining)]
50 return _isWindows ? path.Replace(ReservedWordsPrefix,
string.Empty) : path;