NormalizedPath Structure
Provides properties and instance methods for working with paths.
Namespace
Statiq.Common
Interfaces
Base Types
  • object
  • ValueType
graph BT Type-->Base0["ValueType"] Base0-->Base1["object"] Type-.->Interface0["IDisplayable"] click Interface0 "/api/Statiq.Common/IDisplayable" Type-.->Interface1["IComparable<NormalizedPath>"] Type-.->Interface2["IComparable"] Type-.->Interface3["IEquatable<NormalizedPath>"] Type["NormalizedPath"] class Type type-node

Syntax

public readonly struct NormalizedPath : ValueType, IDisplayable, IComparable<NormalizedPath>, 
    IComparable, IEquatable<NormalizedPath>

Constructors

Name Summary
NormalizedPath(string, PathKind) Initializes a new instance of the NormalizedPath class.
NormalizedPath(string) 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
OptimizeFileNameReservedChars string _~:/\?#[]@!$&'()*+;=};,
static
Slash string /
static
Up NormalizedPath
static

Properties

Name Property Type Summary
DefaultComparisonType 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.
FileNameWithoutExtension 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<char>[]
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(string) NormalizedPath
Appends a file extension to the path.
ChangeExtension(string) NormalizedPath
Changes the file extension of the path.
ChangeFileName(NormalizedPath) NormalizedPath
Changes the file name of the path by combining the specified path with the Parent.
Combine(NormalizedPath, NormalizedPath, NormalizedPath, NormalizedPath) NormalizedPath
static
Combine(NormalizedPath, NormalizedPath, NormalizedPath) NormalizedPath
static
Combine(NormalizedPath, NormalizedPath) NormalizedPath
Combines two paths into a new path.
static
Combine(NormalizedPath) NormalizedPath
Combines the current path with another NormalizedPath. If the provided NormalizedPath is not relative, then it is returned.
Combine(NormalizedPath[]) NormalizedPath
static
CompareTo(NormalizedPath) int
CompareTo(object) int
ContainsChild(NormalizedPath) bool
Checks if this path contains the specified path as a direct child.
ContainsChildOrSelf(NormalizedPath) bool
Checks if this path is the specified path or if this path contains the specified path as a direct child.
ContainsDescendant(NormalizedPath) bool
Checks if this directory contains the specified directory as a descendant.
ContainsDescendantOrSelf(NormalizedPath) bool
Checks if this path is the specified path or if this directory contains the specified directory as a descendant.
Equals(NormalizedPath, StringComparison) bool
Equals(NormalizedPath) bool
Equals(object, StringComparison) bool
Equals(object) bool
GetFilePath(NormalizedPath) NormalizedPath
Combines the current path with the file name of a provided path.
GetHashCode() int
GetHashCode(StringComparison) 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.
GetRelativeOutputPath() 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) NormalizedPath
Get the relative path to another path.
GetTitle() string
Gets a normalized title derived from the file path.
InsertPrefix(string) NormalizedPath
Inserts a prefix into the file name.
InsertSuffix(string) NormalizedPath
Inserts a suffix into the file name before the extension.
IsSibling(NormalizedPath) bool
Checks if this path is a sibling of the specified path.
IsSiblingOrSelf(NormalizedPath) bool
Checks if this path is the specified path or if this path is a sibling of the specified path.
OptimizeFileName(string, bool, bool, bool, bool) NormalizedPath
OptimizeFileName(string, string, bool, bool, bool, bool) string
static
ReplaceInvalidFileNameChars(Span<char>, char) bool
static
ReplaceInvalidFileNameChars(string, char) string
static
ReplaceInvalidPathChars(Span<char>, char) bool
static
ReplaceInvalidPathChars(string, char) string
static
ThrowIfAbsolute(string, string) NormalizedPath
ThrowIfAbsolute(string) NormalizedPath
ThrowIfNull(string) NormalizedPath
ThrowIfRelative(string, string) NormalizedPath
ThrowIfRelative(string) NormalizedPath
ToDisplayString() string
A display string that can be used for tracing.
ToString() string
Returns a string that represents this path.

Operators

Name Value Summary
explicit operator string(NormalizedPath) string
implicit operator NormalizedPath(string) NormalizedPath
operator !=(NormalizedPath, NormalizedPath) bool
operator !=(NormalizedPath, object) bool
operator /(NormalizedPath, NormalizedPath) NormalizedPath
operator ==(NormalizedPath, NormalizedPath) bool
operator ==(NormalizedPath, object) bool

Extension Methods