Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ namespace Pathy
public bool FileExists { get; }
public bool IsDirectory { get; }
public bool IsFile { get; }
public bool IsNull { get; }
public bool IsRooted { get; }
public string Name { get; }
public Pathy.ChainablePath Parent { get; }
public Pathy.ChainablePath Root { get; }
public static Pathy.ChainablePath Current { get; }
public static Pathy.ChainablePath Empty { get; }
public static Pathy.ChainablePath New { get; }
public static Pathy.ChainablePath Null { get; }
public static Pathy.ChainablePath Temp { get; }
public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
public bool HasExtension(string extension) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ namespace Pathy
public bool FileExists { get; }
public bool IsDirectory { get; }
public bool IsFile { get; }
public bool IsNull { get; }
public bool IsRooted { get; }
public string Name { get; }
public Pathy.ChainablePath Parent { get; }
public Pathy.ChainablePath Root { get; }
public static Pathy.ChainablePath Current { get; }
public static Pathy.ChainablePath Empty { get; }
public static Pathy.ChainablePath New { get; }
public static Pathy.ChainablePath Null { get; }
public static Pathy.ChainablePath Temp { get; }
public Pathy.ChainablePath AsRelativeTo(Pathy.ChainablePath basePath) { }
public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ namespace Pathy
public bool FileExists { get; }
public bool IsDirectory { get; }
public bool IsFile { get; }
public bool IsNull { get; }
public bool IsRooted { get; }
public string Name { get; }
public Pathy.ChainablePath Parent { get; }
public Pathy.ChainablePath Root { get; }
public static Pathy.ChainablePath Current { get; }
public static Pathy.ChainablePath Empty { get; }
public static Pathy.ChainablePath New { get; }
public static Pathy.ChainablePath Null { get; }
public static Pathy.ChainablePath Temp { get; }
public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
public bool HasExtension(string extension) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ namespace Pathy
public bool FileExists { get; }
public bool IsDirectory { get; }
public bool IsFile { get; }
public bool IsNull { get; }
public bool IsRooted { get; }
public string Name { get; }
public Pathy.ChainablePath Parent { get; }
public Pathy.ChainablePath Root { get; }
public static Pathy.ChainablePath Current { get; }
public static Pathy.ChainablePath Empty { get; }
public static Pathy.ChainablePath New { get; }
public static Pathy.ChainablePath Null { get; }
public static Pathy.ChainablePath Temp { get; }
public Pathy.ChainablePath AsRelativeTo(Pathy.ChainablePath basePath) { }
public Pathy.ChainablePath FindParentWithFileMatching(params string[] wildcards) { }
Expand Down
4 changes: 2 additions & 2 deletions Pathy.Specs/ChainablePathSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public void Empty_path_returned_when_no_match_found()
var result = childDir.FindParentWithFileMatching("*.sln");

// Assert
result.Should().Be(ChainablePath.Empty);
result.Should().Be(ChainablePath.Null);
}

[Fact]
Expand Down Expand Up @@ -765,7 +765,7 @@ public void Returns_empty_for_non_existing_string_paths()
var result = ChainablePath.FindFirst(nonExistingFile1.ToString(), nonExistingFile2.ToString());

// Assert
result.Should().Be(ChainablePath.Empty);
result.IsNull.Should().BeTrue();
}

[Fact]
Expand Down
13 changes: 13 additions & 0 deletions Pathy/ChainablePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ private ChainablePath(string path)
/// </summary>
public static ChainablePath Empty { get; } = new(string.Empty);

/// <summary>
/// Represents a <see cref="ChainablePath"/> not pointing to any file or directory.
/// </summary>
/// <remarks>
/// Implements the Null Pattern and should be used as a replacement of <see cref="Empty"/>
/// </remarks>
public static ChainablePath Null { get; } = new(string.Empty);

/// <summary>
/// Gets a default, empty <see cref="ChainablePath"/> instance.
/// </summary>
Expand Down Expand Up @@ -221,6 +229,11 @@ private static string NormalizeSlashes(string path)
return From(leftPath.ToString() + additionalPath);
}

/// <summary>
/// Gets a value indicating whether the current <see cref="ChainablePath"/> instance is equal to <see cref="ChainablePath.Null"/>.
/// </summary>
public bool IsNull => Equals(Null);

/// <summary>
/// Gets the name of the file or directory represented by the current path, without the parent directory.
/// </summary>
Expand Down
Loading