Class RelativePath
- Namespace
- DotNetDo
- Assembly
- DotNetDo.Core.dll
An immutable, normalized path relative to an unspecified base.
public sealed record RelativePath : IEquatable<RelativePath>Properties
Empty
The path containing no components, rendered as ..
public static RelativePath Empty { get; }Property Value
Extension
The final component's extension, including its leading period; empty when it has none.
public string Extension { get; }Property Value
Name
The final path component, or null for a root or empty path.
public string? Name { get; }Property Value
NameWithoutExtension
The final component without its last extension; null for DotNetDo.RelativePath.Empty.
public string? NameWithoutExtension { get; }Property Value
Parent
The containing relative path, extending parent traversal beyond DotNetDo.RelativePath.Empty.
public RelativePath Parent { get; }Property Value
UnixPath
Renders the normalized path with forward slashes, regardless of the current platform.
public string UnixPath { get; }Property Value
WindowsPath
Renders the normalized path with backslashes, regardless of the current platform.
public string WindowsPath { get; }Property Value
Methods
Equals(RelativePath?)
Compares normalized path structure using ordinal segment equality.
public bool Equals(RelativePath? other)Parameters
otherRelativePath?
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()Returns
- int
-
A hash code for the current object.
Parse(string)
Normalizes relative path text without accessing the filesystem.
public static RelativePath Parse(string path)Parameters
pathstring-
Relative path text; may use either separator. Rooted, drive-relative, and NUL-containing paths are rejected. Empty and
.produce DotNetDo.RelativePath.Empty.
Returns
QuotedArgument()
Renders the value as one quoted command-line argument.
public string QuotedArgument()Returns
Raw(string)
Creates a one-component relative path without interpreting directory separators in the component.
public static RelativePath Raw(string segment)Parameters
segmentstring-
A non-empty filename or path component. It cannot be
.,.., or contain NUL; directory separators are preserved literally.
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()Returns
- string
-
A string that represents the current object.
Operators
implicit operator string(RelativePath)
Renders the path using the current operating system's directory separator.
public static implicit operator string(RelativePath path)Parameters
pathRelativePath
Returns
operator /(RelativePath, RelativePath)
Combines and normalizes two relative paths, preserving valid leading parent traversal.
public static RelativePath operator /(RelativePath left, RelativePath right)Parameters
leftRelativePath-
The base relative path.
rightRelativePath-
The relative path appended to it.
Returns
operator /(RelativePath, string)
Parses and appends relative path text.
public static RelativePath operator /(RelativePath left, string right)Parameters
leftRelativePath-
The base relative path.
rightstring-
Relative path text; rooted, drive-relative, and NUL-containing values are rejected.