mirror of
https://github.com/oliverbooth/fdup.git
synced 2024-12-04 18:48:48 +00:00
refactor: move stack push to method
reduces method complexity and now Rider isn't crying
This commit is contained in:
parent
435318cd20
commit
3396c2bc74
@ -89,18 +89,7 @@ internal sealed class ListCommand : AsyncCommand<ListSettings>
|
||||
if (relativePath != ".")
|
||||
AnsiConsole.MarkupLineInterpolated($"Searching [cyan]{relativePath}[/]");
|
||||
|
||||
if (settings.Recursive)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (DirectoryInfo childDirectory in currentDirectory.EnumerateDirectories())
|
||||
directoryStack.Push(childDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.MarkupLineInterpolated($"[red]Error:[/] {ex.Message}");
|
||||
}
|
||||
}
|
||||
AddChildDirectories(settings, currentDirectory, directoryStack);
|
||||
|
||||
try
|
||||
{
|
||||
@ -142,6 +131,22 @@ internal sealed class ListCommand : AsyncCommand<ListSettings>
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddChildDirectories(ListSettings settings, DirectoryInfo directory, Stack<DirectoryInfo> stack)
|
||||
{
|
||||
if (!settings.Recursive)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (DirectoryInfo childDirectory in directory.EnumerateDirectories())
|
||||
stack.Push(childDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.MarkupLineInterpolated($"[red]Error:[/] {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static string ByteSpanToString(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
|
Loading…
Reference in New Issue
Block a user