From 98273226ae0ed6737ec7ad97f9814bb94fca8aa2 Mon Sep 17 00:00:00 2001 From: Connor Nemeth <100809777+bfourk@users.noreply.github.com> Date: Sat, 24 Feb 2024 16:57:34 -0500 Subject: [PATCH] Move function Move function into correct file --- FileDiff/FileDiff.cs | 25 +++---------------------- FileDiff/Utils.cs | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/FileDiff/FileDiff.cs b/FileDiff/FileDiff.cs index 286d6ca..964891c 100644 --- a/FileDiff/FileDiff.cs +++ b/FileDiff/FileDiff.cs @@ -8,25 +8,6 @@ namespace FileDiff; public class FDiff { private const int Threads = 16; // Can change to whatever you want - private static void RecreateDirectoryTree(string GarbagePath, string? path) - { - string? DirName = Path.GetDirectoryName(path); - if (DirName == null) - return; - string[] WithoutFile = DirName.Split("/"); - string CurrentPath = ""; - foreach (string str in WithoutFile) - { - if (str == "") - continue; - CurrentPath += string.Format("{0}/",str); - if (!CurrentPath.Contains(".DiffTrash")) - continue; - int index = CurrentPath.IndexOf(".DiffTrash"); - Console.WriteLine(CurrentPath.Substring(index + 11)); - Directory.CreateDirectory(Path.Join(GarbagePath,CurrentPath.Substring(index + 11))); - } - } public static void Main(string[] args) { Stopwatch sw = new Stopwatch(); // For calculating the total time @@ -254,7 +235,7 @@ public static void Main(string[] args) string NewPath = Path.Join(GarbagePath, del); // Re-create directory path in trash folder - RecreateDirectoryTree(GarbagePath, NewPath); + Util.RecreateDirectoryTree(GarbagePath, NewPath); if (File.Exists(NewPath)) { Console.WriteLine("Warn: File with similar name already exists in trash, adding number to beginning"); @@ -276,7 +257,7 @@ public static void Main(string[] args) { string DirPath = Path.Join(SyncDirectory, del); string NewPath = Path.Join(GarbagePath, del); - RecreateDirectoryTree(GarbagePath, NewPath); + Util.RecreateDirectoryTree(GarbagePath, NewPath); if (Directory.Exists(NewPath)) { Console.WriteLine("Warn: File with similar name already exists in trash, adding number to beginning"); @@ -293,4 +274,4 @@ public static void Main(string[] args) } Console.WriteLine("Finished"); } -} +} \ No newline at end of file diff --git a/FileDiff/Utils.cs b/FileDiff/Utils.cs index b4db017..403a7eb 100644 --- a/FileDiff/Utils.cs +++ b/FileDiff/Utils.cs @@ -38,6 +38,24 @@ public static bool CompareFiles(string path1, string path2) } return CompareHash(Hash1, Hash2); } + public static void RecreateDirectoryTree(string GarbagePath, string? path) + { + string? DirName = Path.GetDirectoryName(path); + if (DirName == null) + return; + string[] WithoutFile = DirName.Split("/"); + string CurrentPath = ""; + foreach (string str in WithoutFile) + { + if (str == "") + continue; + CurrentPath += string.Format("{0}/",str); + if (!CurrentPath.Contains(".DiffTrash")) + continue; + int index = CurrentPath.IndexOf(".DiffTrash"); + Directory.CreateDirectory(Path.Join(GarbagePath,CurrentPath.Substring(index + 11))); + } + } // // Misc. Functions