diff --git a/GenericStripper/Modules/BeatSaber/BeatSaber.cs b/GenericStripper/Modules/BeatSaber/BeatSaber.cs index 7b83a34..a6be1e3 100644 --- a/GenericStripper/Modules/BeatSaber/BeatSaber.cs +++ b/GenericStripper/Modules/BeatSaber/BeatSaber.cs @@ -31,21 +31,23 @@ public void StripDll(string file, string outDir, params string[] resolveDirs) bsAssemblyModule.Virtualize(); bsAssemblyModule.Strip(); - Directory.CreateDirectory(Path.Combine(outDir, Path.GetRelativePath(GamePath, fileInf.Directory!.ToString()))); - var outFile = Path.Combine(outDir, Path.GetRelativePath(GamePath, fileInf.FullName)); - bsAssemblyModule.Write(outFile); + var relativePath = Path.GetRelativePath(GamePath, fileInf.FullName); + var outAssembly = Path.Combine(outDir, relativePath); + if (!Directory.Exists(Path.GetDirectoryName(outAssembly))) + Directory.CreateDirectory(Path.GetDirectoryName(outAssembly) ?? string.Empty); + + bsAssemblyModule.Write(outAssembly); } public async Task StripAllDlls(string outDir) { await InstallBsipa(); + if (!Directory.Exists(outDir)) Directory.CreateDirectory(outDir); + var bsLibsDir = Path.Combine(GamePath, "Libs"); var bsManagedDir = Path.Combine(GamePath, "Beat Saber_Data", "Managed"); - var outputDir = Path.Combine(GamePath, outDir); - if (!Directory.Exists(outputDir)) Directory.CreateDirectory(outputDir); - var libAssemblies = Directory.GetFiles(bsLibsDir, "*.dll", SearchOption.AllDirectories); var managedAssemblies = Directory.GetFiles(bsManagedDir, "*.dll", SearchOption.AllDirectories); @@ -59,9 +61,19 @@ public async Task StripAllDlls(string outDir) foreach (var assembly in libAssemblies.Concat(managedAssemblies)) { - StripDll(assembly, outputDir, bsLibsDir, bsManagedDir); + var assemblyInf = new FileInfo(assembly); + var relativePath = Path.GetRelativePath(GamePath, assemblyInf.FullName); + var outAssembly = Path.Combine(outDir, relativePath); + if (File.Exists(outAssembly)) + { + task.Increment(1); + AnsiConsole.MarkupLine($"[gray]Skipped {assemblyInf.Name}[/]"); + continue; + } + + StripDll(assembly, outDir, bsLibsDir, bsManagedDir); task.Increment(1); - AnsiConsole.MarkupLine($"[teal]Stripped {assembly}[/]"); + AnsiConsole.MarkupLine($"[teal]Stripped {assemblyInf.Name}[/]"); } } );