Skip to content

Commit

Permalink
fix: output directory is now a path, not relative to gamedir
Browse files Browse the repository at this point in the history
  • Loading branch information
ChecksumDev committed Aug 28, 2023
1 parent f30b594 commit 3f44957
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions GenericStripper/Modules/BeatSaber/BeatSaber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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}[/]");
}
}
);
Expand Down

0 comments on commit 3f44957

Please sign in to comment.