Skip to content

Commit

Permalink
- Splits the file tree logging into one log entry per top level folder
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimeSonic committed Aug 6, 2020
1 parent 50836f8 commit 6b0e2d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion QModManager/Patching/Patcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ internal static void Patch()

try
{
Logger.Info($"Folder structure:{IOUtilities.GetFolderStructureAsTree()}");
Logger.Info($"Folder structure:");
IOUtilities.LogFolderStructureAsTree();
}
catch (Exception e)
{
Expand Down
13 changes: 9 additions & 4 deletions QModManager/Utility/IOUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,36 @@ internal static class IOUtilities
"steam_shader_cache",
};

internal static string GetFolderStructureAsTree(string directory = null)
internal static void LogFolderStructureAsTree(string directory = null)
{
try
{
directory ??= Environment.CurrentDirectory;

return GenerateFolderStructure(directory);
GenerateFolderStructure(directory);
}
catch (Exception e)
{
throw e;
}
}

internal static string GenerateFolderStructure(string directory)
internal static void GenerateFolderStructure(string directory)
{
var builder = new StringBuilder();

try
{
builder.AppendLine();
builder.AppendLine($"+ {new DirectoryInfo(directory).Name}");

Logger.Info(builder.ToString());
builder.Clear();
foreach (string dir in Directory.GetDirectories(directory))
{
GetFolderStructureRecursively(builder, dir, 0);
Logger.Info(builder.ToString());
builder.Clear();
}

string[] files = Directory.GetFiles(directory);
Expand All @@ -60,7 +65,7 @@ internal static string GenerateFolderStructure(string directory)
}

builder.AppendLine();
return builder.ToString();
Logger.Info(builder.ToString());
}
catch (Exception e)
{
Expand Down

0 comments on commit 6b0e2d2

Please sign in to comment.