Skip to content

Commit

Permalink
revert public API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Bollhalder committed Oct 24, 2023
1 parent c12641d commit 5320f39
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Zio.Tests/TestSearchPattern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void TestExtensions()
var newPath = path.ChangeExtension(".zip");
Assert.Equal("/a/b/c/d.zip", newPath.FullName);
Assert.Equal(new UPath("a/b/c/d.txt"), path.ToRelative());
path.AssertNotNull();
Assert.Equal(path, path.AssertAbsolute());
Assert.Throws<ArgumentNullException>(() => new UPath().AssertNotNull());
Assert.Throws<ArgumentException>(() => new UPath("not_absolute").AssertAbsolute());
}
Expand Down
3 changes: 1 addition & 2 deletions src/Zio/FileSystems/SubFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public class SubFileSystem : ComposeFileSystem
/// <exception cref="DirectoryNotFoundException">If the directory subPath does not exist in the delegate FileSystem</exception>
public SubFileSystem(IFileSystem fileSystem, UPath subPath, bool owned = true) : base(fileSystem, owned)
{
subPath.AssertAbsolute(nameof(subPath));
SubPath = subPath;
SubPath = subPath.AssertAbsolute(nameof(subPath));
if (!fileSystem.DirectoryExists(SubPath))
{
throw NewDirectoryNotFoundException(SubPath);
Expand Down
8 changes: 6 additions & 2 deletions src/Zio/UPathExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,13 @@ public static bool IsInDirectory(this UPath path, UPath directory, bool recursiv
/// <param name="path">The path.</param>
/// <param name="name">The name of a parameter to include n the <see cref="ArgumentNullException"/>.</param>
/// <exception cref="System.ArgumentNullException">If the path was null using the parameter name from <paramref name="name"/></exception>
public static void AssertNotNull(this UPath path, string name = "path")
public static UPath AssertNotNull(this UPath path, string name = "path")
{
if (path.IsNull)
Throw(name);

return path;

static void Throw(string name) => throw new ArgumentNullException(name);
}

Expand All @@ -254,11 +256,13 @@ public static void AssertNotNull(this UPath path, string name = "path")
/// <param name="path">The path.</param>
/// <param name="name">The name of a parameter to include n the <see cref="ArgumentNullException"/>.</param>
/// <exception cref="System.ArgumentException">If the path is not absolute using the parameter name from <paramref name="name"/></exception>
public static void AssertAbsolute(this UPath path, string name = "path")
public static UPath AssertAbsolute(this UPath path, string name = "path")
{
if (!path.IsAbsolute)
Throw(path, name);

return path;

static void Throw(UPath path, string name) => throw new ArgumentException($"Path `{path}` must be absolute", name);
}
}

0 comments on commit 5320f39

Please sign in to comment.