Add an automation-friendly command-line version (continues #394) - #670
Open
Alex123666tw wants to merge 6 commits into
Open
Add an automation-friendly command-line version (continues #394)#670Alex123666tw wants to merge 6 commits into
Alex123666tw wants to merge 6 commits into
Conversation
Improved code style
…Get.targets The MSBuild-integrated package restore (Import of .nuget\NuGet.targets plus the EnsureNuGetPackageBuildImports guard target) predates automatic restore and breaks on modern toolchains because the .nuget folder is not committed. Packages are restored with nuget restore (or Visual Studio), so drop the gate from GameRes, ArcFormats and GARbro.GUI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This command-line build is meant to be driven as a child process, but a few behaviours made that unreliable: - The overwrite prompt blocked on Console.ReadKey() with no way to answer from a script. Add -y/--overwrite, -s/--skip and -r/--rename, and fall back to overwrite when stdin is redirected (no interactive console). - The process always exited 0, even on failure. PrintError now sets Environment.ExitCode, and extraction returns non-zero when files are skipped. - Banner, progress, warnings and errors went to stdout and polluted the machine-readable i/l output. Route them to stderr; add -q/--quiet. - Remove a leftover debug print of the first entry offset. - Fix an inverted filter check in the non-archive code path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Archive entry names are attacker-controlled. CreateNewFile combined the entry name into the output directory without containment, so an entry named with ..\ segments or an absolute path could write outside the chosen output directory (arbitrary file write). Resolve the output root and the target path to full paths and reject any target that does not sit under the output root (case-insensitive, with a trailing separator to avoid sibling-prefix bypass). The thrown UnauthorizedAccessException is caught by the per-entry catch (Exception) in Archive_ExtractFiles, so a malicious entry is skipped and the process exits non-zero rather than crashing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…k -if
(a) In the non-archive path, the "Converting <fmt> audio" progress line
and the "All OK" success line were written to stdout, contaminating
the clean-stdout contract that parent processes rely on. Route both
to stderr (the archive path already does this).
(b) The -if switch read args[i] without checking for a missing value,
throwing IndexOutOfRangeException. Add the same bounds check already
used by -o and -f: PrintError + return when the value is absent.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
Pushed two follow-up commits to this branch:
Verified with a byte-for-byte extraction regression (a real SoftPal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This continues @Bioruebe's #394 (a new command-line version of GARbro), rebased onto current
master, with changes that make the CLI usable as a child process driven by other tools.What's here
iidentify /fformats /llist /xextract) from Added new command line version #394 by @Bioruebe — both commits cherry-picked with their original authorship preserved.-y/-s/-r, and fall back to overwrite automatically when stdin is redirected. The previous code blocked onConsole.ReadKey()with no way to answer from a script.PrintErrornow setsEnvironment.ExitCode, and extraction returns non-zero when files are skipped (it always exited0before).i/ldata on stdout is clean to parse; add-q.<Import ...\.nuget\NuGet.targets>+EnsureNuGetPackageBuildImportsgate from GameRes / ArcFormats / GUI so the solution builds on modern MSBuild vianuget restore(the.nugetfolder is not in the tree).Verified
Built Console + GameRes + ArcFormats (Release) with VS Build Tools 2022. On a SoftPal
PAC/AMUSEarchive, the extractedSCRIPT.SRC/TEXT.DAT/POINT.DATare byte-for-byte identical (SHA-256) to reference output.Note
This is also maintained, with prebuilt Windows releases, at https://github.com/Alex123666tw/garbro-cli (MIT). Happy to split commits, narrow the scope, or drop the build/doc parts if you'd prefer a more minimal PR.