Table of Contents

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

RelativePath

Extension

The final component's extension, including its leading period; empty when it has none.

public string Extension { get; }

Property Value

string

Name

The final path component, or null for a root or empty path.

public string? Name { get; }

Property Value

string?

NameWithoutExtension

The final component without its last extension; null for DotNetDo.RelativePath.Empty.

public string? NameWithoutExtension { get; }

Property Value

string?

Parent

The containing relative path, extending parent traversal beyond DotNetDo.RelativePath.Empty.

public RelativePath Parent { get; }

Property Value

RelativePath

UnixPath

Renders the normalized path with forward slashes, regardless of the current platform.

public string UnixPath { get; }

Property Value

string

WindowsPath

Renders the normalized path with backslashes, regardless of the current platform.

public string WindowsPath { get; }

Property Value

string

Methods

Equals(RelativePath?)

Compares normalized path structure using ordinal segment equality.

public bool Equals(RelativePath? other)

Parameters

other RelativePath?

Returns

bool

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

path string

Relative path text; may use either separator. Rooted, drive-relative, and NUL-containing paths are rejected. Empty and . produce DotNetDo.RelativePath.Empty.

Returns

RelativePath

QuotedArgument()

Renders the value as one quoted command-line argument.

public string QuotedArgument()

Returns

string

Raw(string)

Creates a one-component relative path without interpreting directory separators in the component.

public static RelativePath Raw(string segment)

Parameters

segment string

A non-empty filename or path component. It cannot be ., .., or contain NUL; directory separators are preserved literally.

Returns

RelativePath

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

path RelativePath

Returns

string

operator /(RelativePath, RelativePath)

Combines and normalizes two relative paths, preserving valid leading parent traversal.

public static RelativePath operator /(RelativePath left, RelativePath right)

Parameters

left RelativePath

The base relative path.

right RelativePath

The relative path appended to it.

Returns

RelativePath

operator /(RelativePath, string)

Parses and appends relative path text.

public static RelativePath operator /(RelativePath left, string right)

Parameters

left RelativePath

The base relative path.

right string

Relative path text; rooted, drive-relative, and NUL-containing values are rejected.

Returns

RelativePath