Skip to content

Commit

Permalink
add common file extensions for gfpak export
Browse files Browse the repository at this point in the history
  • Loading branch information
Reisyukaku committed Nov 14, 2019
1 parent df532ad commit 593f7ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SPICA.WinForms/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private void ToolButtonExport_Click(object sender, EventArgs e)
private void ExtractGfpak(string pak, string outPath) {
GFLXPack gfpak = new GFLXPack(pak);
for (int i = 0; i < gfpak.FileCnt; i++) {
using (BinaryWriter bw = new BinaryWriter(new FileStream(outPath + "/" + gfpak.GetName(i) + ".bin", FileMode.CreateNew))) {
using (BinaryWriter bw = new BinaryWriter(new FileStream(outPath + "/" + gfpak.GetName(i), FileMode.CreateNew))) {
byte[] file = gfpak.GetFile(i);
bw.Write(file);
bw.Close();
Expand Down
18 changes: 17 additions & 1 deletion SPICA/Formats/GFLX/GFLXPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,27 @@ public GFLXPack(string path)
UInt32 zsize = br.ReadUInt32();
br.ReadUInt32(); //dummy
UInt64 offset = br.ReadUInt64();
Names.Add(offset.ToString("X8"));
br.BaseStream.Position = (long)offset;
byte[] compData = br.ReadBytes((int)zsize);
byte[] decompData = new byte[size];
var decoded = LZ4Codec.Decode(compData, 0, compData.Length, decompData, 0, decompData.Length);
string ext = string.Empty;
switch (BitConverter.ToUInt32(decompData, 0))
{
case 0x58544E42:
ext = ".btnx";
break;
case 0x48534E42:
ext = ".bnsh";
break;
case 0x20:
ext = ".gfmdl";
break;
default:
ext = ".bin";
break;
}
Names.Add(offset.ToString("X8") + ext);
Files.Add(decompData);
}
}
Expand Down

0 comments on commit 593f7ec

Please sign in to comment.