From 03e3db2c4a63b8ec206d281980de855ce2207fd3 Mon Sep 17 00:00:00 2001 From: hamdiakin Date: Tue, 6 Oct 2026 00:53:51 +0300 Subject: [PATCH 1/3] PathIo: support LocalPathPattern in GetFiles --- TruePath.SystemIo/PathIo.cs | 8 ++++++++ TruePath.Tests/PathIoTests.cs | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/TruePath.SystemIo/PathIo.cs b/TruePath.SystemIo/PathIo.cs index 9844a79..f32fc2e 100644 --- a/TruePath.SystemIo/PathIo.cs +++ b/TruePath.SystemIo/PathIo.cs @@ -743,6 +743,14 @@ public static class PathIo /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern. public static string[] GetFiles(this AbsolutePath path, string searchPattern) => Directory.GetFiles(path.Value, searchPattern); + /// + /// Returns the names of files (including their paths) that match the specified search pattern in the specified directory. + /// + /// The directory to search. + /// The search pattern to match against the names of files in . + /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern. + public static string[] GetFiles(this AbsolutePath path, LocalPathPattern searchPattern) => Directory.GetFiles(path.Value, searchPattern.Value); + #if NET8_0_OR_GREATER /// /// Returns the names of files (including their paths) that match the specified search pattern and enumeration options in the specified directory. diff --git a/TruePath.Tests/PathIoTests.cs b/TruePath.Tests/PathIoTests.cs index d581fa8..9833816 100644 --- a/TruePath.Tests/PathIoTests.cs +++ b/TruePath.Tests/PathIoTests.cs @@ -40,6 +40,21 @@ public void ExistsFolderTest() }); } + [Fact] + public void GetFilesByLocalPathPatternTest() + { + DoWithTempFolder(tempFolder => + { + var matchingFile = tempFolder / "matching.txt"; + matchingFile.WriteAllText("test"); + (tempFolder / "other.log").WriteAllText("test"); + + var files = tempFolder.GetFiles(new LocalPathPattern("*.txt")); + + Assert.Equal([matchingFile.Value], files); + }); + } + private static void DoWithTempFolder(Action test) { var tempFolder = Temporary.CreateTempFolder(); From 8af0e6ca11c7dc80a7c17b29c4f90a51492ff011 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Wed, 21 Oct 2026 23:41:03 +0200 Subject: [PATCH 2/3] (#202) PathIo: return an array of AbsolutePaths --- TruePath.SystemIo/PathIo.cs | 8 ++++++-- TruePath.Tests/PathIoTests.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/TruePath.SystemIo/PathIo.cs b/TruePath.SystemIo/PathIo.cs index f32fc2e..338e675 100644 --- a/TruePath.SystemIo/PathIo.cs +++ b/TruePath.SystemIo/PathIo.cs @@ -748,8 +748,12 @@ public static class PathIo /// /// The directory to search. /// The search pattern to match against the names of files in . - /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern. - public static string[] GetFiles(this AbsolutePath path, LocalPathPattern searchPattern) => Directory.GetFiles(path.Value, searchPattern.Value); + /// + /// An array of the absolute paths for the files in the specified directory that match the specified search + /// pattern. + /// + public static AbsolutePath[] GetFiles(this AbsolutePath path, LocalPathPattern searchPattern) => + Directory.GetFiles(path.Value, searchPattern.Value).Select(x => new AbsolutePath(x)).ToArray(); #if NET8_0_OR_GREATER /// diff --git a/TruePath.Tests/PathIoTests.cs b/TruePath.Tests/PathIoTests.cs index 9833816..9837266 100644 --- a/TruePath.Tests/PathIoTests.cs +++ b/TruePath.Tests/PathIoTests.cs @@ -51,7 +51,7 @@ public void GetFilesByLocalPathPatternTest() var files = tempFolder.GetFiles(new LocalPathPattern("*.txt")); - Assert.Equal([matchingFile.Value], files); + Assert.Equal([matchingFile], files); }); } From 2927649207267abfca4e3cbd3edb63c4ba77c220 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Wed, 21 Oct 2026 23:41:41 +0200 Subject: [PATCH 3/3] (#202) Docs: add a changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73f67ce..7fd0bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `LocalPath.PathRoot`, returning the root of an absolute path, or the drive root of a drive-relative path (e.g. `C:foo`, which only exists on Windows), or `null` when the root can't be determined. - `AbsolutePath.PathRoot` property. - [#224](https://github.com/ForNeVeR/TruePath/issues/224): `PathKind` enumeration and `LocalPath.Kind` property, telling an absolute path from a relative one, and on Windows also from a path rooted without a drive letter (`\Windows`) and from a path relative to the current directory of a drive (`C:Windows`). These are **experimental** (diagnostic `TRUEPATH001`): more kinds may be added later, e.g. for UNC paths. +- [#202: `path.GetFiles(LocalPathPattern)`](https://github.com/ForNeVeR/TruePath/issues/202). ### Changed - **Breaking:** on Windows, `LocalPath.IsAbsolute` now only returns `true` for fully qualified paths, such as `C:\Windows`. Paths rooted without a drive letter (`\Windows`), and paths relative to the current directory of a drive (`C:Windows`, `C:`) are not absolute anymore, and `AbsolutePath` now rejects them. Previously, this was following the `Path.IsPathRooted` API.