Skip to content
ConsoleMonster
Class

DisplayPath

ConsoleMonster.Text

Namespace
ConsoleMonster.Text
Assembly
ConsoleMonster
Modifiers
static

Paths for display that may come from another system: recorded test runs, imported stack traces and error records carry Windows paths that a Unix host's path APIs would not split (a backslash is not a separator there), and the reverse. These helpers work on the text of the path, so the same path looks the same on every host; paths that belong to the host still go through its own path APIs for I/O.

Inheritance

  • object
  • DisplayPath

Methods

public static string FileName(string? path) #

The last segment of a path, splitting on both \ and /.

Parameters

path string? required
The path.

Returns

string The file name, or the path itself when it has no separator.
IsForeign 2 overloads
public static bool IsForeign(string? path) #

Whether a path belongs to another kind of system than the current host (a drive or UNC path on Unix, a rooted Unix path on Windows).

Parameters

path string? required
The path.

Returns

bool True for a foreign path.
public static bool IsForeign(string? path, bool hostIsWindows) #

Whether a path belongs to another kind of system than a host of the given kind.

Parameters

path string? required
The path.
hostIsWindows bool required
Whether the host is Windows.

Returns

bool True for a foreign path.
public static string Short(string path, string? basePath) #

A short form of a path as text: relative to basePath when under it (compared without regard to case or separator style), otherwise its folder and file name, keeping the path's own separator.

Parameters

path string required
The path.
basePath string? required
The base path, or null.

Returns

string The short path.