Skip to content

Commit

Permalink
Extracted contents of XC archives.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Nov 12, 2024
1 parent 7cd9ecd commit a431df6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public void GatherFileBundles(
return;
}

var extractor = new XcArchiveExtractor();
foreach (var xcFile in
fileHierarchy.Root.GetFilesWithFileType(".xc", true)) {
extractor.ExtractIntoDirectory(xcFile,
new FinDirectory(
xcFile.AssertGetParent().FullPath));
}

if (new ThreeDsXfsaTool().Extract(fileHierarchy.Root.GetExistingFiles()
.SingleByName("vs1.fa"))) {
fileHierarchy.Root.Refresh(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using fin.data.dictionaries;
using fin.io;

using level5.schema;

using schema.binary;


namespace uni.games.professor_layton_vs_phoenix_wright;

internal class XcArchiveExtractor {
public void ExtractIntoDirectory(IReadOnlyTreeFile xcFile,
ISystemDirectory dstDirectory) {
dstDirectory = new FinDirectory(
Path.Join(dstDirectory.FullPath, xcFile.NameWithoutExtension));
if (dstDirectory is {Exists: true, IsEmpty: false}) {
return;
}

dstDirectory.Create();

var xc = xcFile.ReadNew<Xc>(Endianness.LittleEndian);
foreach (var (extension, files) in xc.FilesByExtension.GetPairs()) {
foreach (var file in files) {
var dstFile = new FinFile(Path.Join(dstDirectory.FullPath, file.Name));
dstFile.WriteAllBytes(file.Data);
}
}
}
}

0 comments on commit a431df6

Please sign in to comment.