1using static System.IO.Path;
18 public static bool IsWindows => DirectorySeparatorChar ==
'\\';
24 public OSPath(
string text) => Text = text.Trim();
30 public static implicit
operator OSPath(
string text) =>
new OSPath(text);
36 public static implicit
operator string(
OSPath path) => path.Normalized;
44 protected string Text {
get; }
54 public string Windows => Text.Replace(
'/',
'\\');
74 public bool IsRooted => Text.Length >= 1 && (Text[0] ==
'/' || Text[0] ==
'\\');
79 public bool HasVolume => Text.Length >= 2 && Text[1] ==
':';
93 var parent = GetDirectoryName(Text);
97 var root = GetPathRoot(Text);
125 new OSPath(Combine(left, right.Relative));
135 ?
new OSPath(left.Normalized.Substring(right.Normalized.Length)).Relative
Represents an operating system path and provides methods for path conversion and manipulation.
string Normalized
Gets the normalized path based on the current operating system.
static readonly OSPath Empty
Represents an empty OSPath.
string Unix
Gets the Unix-style path.
OSPath Parent
Gets the parent directory of the path.
OSPath Simplified
Gets the rooted path without the drive letter.
static OSPath operator-(OSPath left, OSPath right)
Removes the specified path from the current path.
OSPath Relative
Gets the path without the root or drive letter.
bool HasVolume
Gets a value indicating whether the path has a drive letter.
OSPath(string text)
Initializes a new instance of the OSPath class with the specified text.
static OSPath operator+(OSPath left, OSPath right)
Concatenates two paths.
bool IsAbsolute
Gets a value indicating whether the path is absolute.
bool Contains(OSPath path)
Determines whether the current path contains the specified path.
static bool IsWindows
Gets a value indicating whether the current operating system is Windows.
override string ToString()
bool IsRooted
Gets a value indicating whether the path is rooted.
string Text
Gets the original path text.
string Windows
Gets the Windows-style path.