Skip to content
Merged
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
51 changes: 51 additions & 0 deletions TruePath.SystemIo/PathIo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,55 @@ public static class PathIo
/// <param name="searchOption">One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories.</param>
/// <returns>An array of the full names (including paths) for the subdirectories in the specified directory that match the specified search pattern and option.</returns>
public static string[] GetDirectories(this AbsolutePath path, string searchPattern, SearchOption searchOption) => Directory.GetDirectories(path.Value, searchPattern, searchOption);

/// <summary>
/// Returns an enumerable collection of <see cref="AbsolutePath"/> of full file names in a specified path.
/// </summary>
/// <param name="path">The directory to search.</param>
/// <returns>An enumerable collection of <see cref="AbsolutePath"/> of the full names (including paths) for the files in the specified directory that match the specified search pattern.</returns>
public static IEnumerable<AbsolutePath> EnumerateFiles(this AbsolutePath path)
{
return Directory.EnumerateFiles(path.Value)
.Select(filename => path / filename);
}

/// <summary>
/// Returns an enumerable collection of <see cref="AbsolutePath"/> of full file names in a specified path.
/// </summary>
/// <param name="path">The directory to search.</param>
/// <param name="searchPattern">The search string to match against the names of files in <paramref name="path"/>.</param>
/// <returns>An enumerable collection of <see cref="AbsolutePath"/> of the full names (including paths) for the files in the specified directory that match the specified search pattern.</returns>
public static IEnumerable<AbsolutePath> EnumerateFiles(this AbsolutePath path, string searchPattern)
{
return Directory.EnumerateFiles(path.Value, searchPattern)
.Select(filename => path / filename);
}

#if NET8_0_OR_GREATER
/// <summary>
/// Returns an enumerable collection of <see cref="AbsolutePath"/> of the names of files (including their paths) that match the specified search pattern and enumeration options in the specified directory.
/// </summary>
/// <param name="path">The directory to search.</param>
/// <param name="searchPattern">The search string to match against the names of files in <paramref name="path"/>.</param>
/// <param name="enumerationOptions">An object that contains the search options to use.</param>
/// <returns>An enumerable collection of <see cref="AbsolutePath"/> of the full names (including paths) for the files in the specified directory that match the specified search pattern and enumeration options.</returns>
public static IEnumerable<AbsolutePath> EnumerateFiles(this AbsolutePath path, string searchPattern, EnumerationOptions enumerationOptions)
{
return Directory.EnumerateFiles(path.Value, searchPattern, enumerationOptions)
.Select(filename => path / filename);
}
#endif

/// <summary>
/// Returns an enumerable collection of <see cref="AbsolutePath"/> with the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.
/// </summary>
/// <param name="path">The directory to search.</param>
/// <param name="searchPattern">The search string to match against the names of files in <paramref name="path"/>.</param>
/// <param name="searchOption">One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories.</param>
/// <returns>An enumerable collection of <see cref="AbsolutePath"/> of the full names (including paths) for the files in the specified directory that match the specified search pattern.</returns>
public static IEnumerable<AbsolutePath> EnumerateFiles(this AbsolutePath path, string searchPattern, SearchOption searchOption)
{
return Directory.EnumerateFiles(path.Value, searchPattern, searchOption)
.Select(filename => path / filename);
}
}