Provides properties and instance methods for working with paths.
- Namespace
- Statiq
.Common - Interfaces
-
- IDisplayable
- IComparable
<NormalizedPath> - IComparable
- IEquatable
<NormalizedPath>
- Base Types
-
- object
- ValueType
Syntax
public readonly struct NormalizedPath : ValueType, IDisplayable, IComparable<NormalizedPath>,
IComparable, IEquatable<NormalizedPath>
Constructors
| Name | Summary |
|---|---|
| NormalizedPath |
Initializes a new instance of the NormalizedPath class.
|
| NormalizedPath |
Initializes a new instance of the NormalizedPath class.
|
Fields
| Name | Field Type | Constant Value | Summary |
|---|---|---|---|
| AbsoluteRoot | NormalizedPath |
static
|
|
| Current | NormalizedPath |
static
|
|
| Dot | string | . |
static
|
| DotDot | string | .. |
static
|
| Empty | NormalizedPath |
static
|
|
| Null | NormalizedPath |
static
|
|
| Optimize |
string | _~:/\?#[]@!$&'()*+={};, |
static
|
| Slash | string | / |
static
|
| Up | NormalizedPath |
static
|
Properties
| Name | Property Type | Summary |
|---|---|---|
| Default |
StringComparison |
The type of string comparison to perform when comparing paths.
static
|
| Extension | string |
Gets the file extension (including the preceding ".").
|
| FileName | NormalizedPath |
Gets the filename.
|
| File |
NormalizedPath |
Gets the filename without it's extension.
|
| FullPath | string |
Gets the full path as a string.
|
| HasExtension | bool |
Gets a value indicating whether this path has a file extension.
|
| IsAbsolute | bool |
Gets or sets a value indicating whether this path is absolute.
|
| IsNull | bool |
Indicates if this is a null path.
|
| IsNullOrEmpty | bool |
Indicates if this is a null or empty path.
|
| IsRelative | bool |
Gets a value indicating whether this path is relative.
|
| MediaType | string |
Gets the media type of the path.
|
| Name | string |
Gets the name of the directory or file.
|
| Parent | NormalizedPath |
Gets the parent path or
Empty if this is a relative path with no parent.
|
| Root | NormalizedPath |
Gets the root of this path,
Empty if this is a relative path,
or Null if there is no root.
|
| RootRelative | NormalizedPath |
Gets current path relative to it's root. If this is already a relative
path or there is no root path, this just returns the current path.
|
| Segments | ReadOnlyMemory |
Gets the segments making up the path. These are slices of the
FullPath and can be converted to either
ReadOnlySpan<T> or string as needed.
This does not include directory separator characters
or the leading slash if there is one.
|
Methods
| Name | Return Value | Summary |
|---|---|---|
| AppendExtension |
NormalizedPath |
Appends a file extension to the path.
|
| ChangeExtension |
NormalizedPath |
Changes the file extension of the path.
|
| ChangeFileName |
NormalizedPath |
Changes the file name of the path by combining the specified path with the
Parent.
|
| Combine |
NormalizedPath |
static
|
| Combine |
NormalizedPath |
static
|
| Combine |
NormalizedPath |
Combines two paths into a new path.
static
|
| Combine |
NormalizedPath |
Combines the current path with another
NormalizedPath.
If the provided NormalizedPath is not relative, then it is returned.
|
| Combine |
NormalizedPath |
static
|
| CompareTo |
int | |
| CompareTo |
int | |
| ContainsChild |
bool |
Checks if this path contains the specified path as a direct child.
|
| ContainsChildOrSelf |
bool |
Checks if this path is the specified path or if this path contains the specified path as a direct child.
|
| ContainsDescendant |
bool |
Checks if this directory contains the specified directory as a descendant.
|
| Contains |
bool |
Checks if this path is the specified path or if this directory contains the specified directory as a descendant.
|
| Equals |
bool | |
| Equals |
bool | |
| Equals |
bool | |
| Equals |
bool | |
| GetFilePath |
NormalizedPath |
Combines the current path with the file name of a provided path.
|
| GetHashCode |
int | |
| GetHashCode |
int | |
| GetRelativeInputPath |
NormalizedPath |
Gets a path to this file relative to it's containing input directory in the current file system.
If no input directories contain this file, then a null path is returned.
|
| Get |
NormalizedPath |
Gets a path to this file relative to the output directory in the current file system.
If this path is not relative to the output directory, then a null path is returned.
|
| GetRelativePath |
NormalizedPath |
Get the relative path to another path.
|
| GetTitle |
string |
Gets a normalized title derived from the file path.
|
| InsertPrefix |
NormalizedPath |
Inserts a prefix into the file name.
|
| InsertSuffix |
NormalizedPath |
Inserts a suffix into the file name before the extension.
|
| IsSibling |
bool |
Checks if this path is a sibling of the specified path.
|
| IsSiblingOrSelf |
bool |
Checks if this path is the specified path or if this path is a sibling of the specified path.
|
| OptimizeFileName |
NormalizedPath | |
| OptimizeFileName |
string |
static
|
| Replace |
bool |
static
|
| Replace |
string |
static
|
| Replace |
bool |
static
|
| Replace |
string |
static
|
| ThrowIfAbsolute |
NormalizedPath | |
| ThrowIfAbsolute |
NormalizedPath | |
| ThrowIfNull |
NormalizedPath | |
| ThrowIfRelative |
NormalizedPath | |
| ThrowIfRelative |
NormalizedPath | |
| ToDisplayString |
string |
A display string that can be used for tracing.
|
| ToDisplayString |
string |
A display string that can be used for tracing that displays a custom message if the path is null.
|
| ToString |
string |
Returns a
string that represents this path.
|
Operators
| Name | Value | Summary |
|---|---|---|
| explicit operator string |
string | |
| implicit operator |
NormalizedPath | |
| operator != |
bool | |
| operator != |
bool | |
| operator / |
NormalizedPath | |
| operator == |
bool | |
| operator == |
bool |