Skip to content

Commit

Permalink
Add --paths parameter (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-zk committed Sep 24, 2023
1 parent 44ce7c8 commit efd88bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Extractor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ static void Main(string[] args)
$"The output directory.\nDefault: {destination}",
x => { destination = x; } },
{ "headers-at-end",
"Ignores what the archive header says and reads entry headers from the end of the file.",
"Ignores what the archive header says and reads entry headers " +
"from the end of the file.",
x => { forceEntryHeadersAtEnd = true; } },
{ "p=|partial=",
"Partial extraction, e.g.:\n" +
"-p=/map\n" +
"-p=/def,/map\n" +
"-p=/def/world/road.sii",
x => { startPaths = x.Split(","); } },
{ "paths=",
"Same as --partial, but expects a text file containing paths to extract, " +
"separated by newlines.",
x => { startPaths = LoadStartPathsFromFile(x); } },
{ "r|raw",
"Directly dumps the contained files with their hashed filenames rather than " +
"traversing the archive's directory tree. " +
Expand Down Expand Up @@ -90,6 +95,14 @@ static void Main(string[] args)
}
}

private static string[] LoadStartPathsFromFile(string file)
{
if (!File.Exists(file)) {
Console.WriteLine($"File {file} does not exist");
}
return File.ReadAllLines(file).Where(l => !string.IsNullOrWhiteSpace(l)).ToArray();
}

private static void ExtractAllInDirectory(string directory, string[] startPaths)
{
if (!Directory.Exists(directory))
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Options:
-p=/map
-p=/def,/map
-p=/def/world/road.sii
--paths=VALUE Same as --partial, but expects a text file
containing paths to extract, separated by
newlines.
-r, --raw Directly dumps the contained files with their
hashed filenames rather than traversing the
archive's directory tree. This allows for the
Expand Down

0 comments on commit efd88bb

Please sign in to comment.