DisplayPath
ConsoleMonster.Text
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?
- The path.
Returns
string The file name, or the path itself when it has no separator.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?
- 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?
- The path.
- hostIsWindows bool
- 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
- The path.
- basePath string?
- The base path, or null.
Returns
string The short path.