From 593f7ecbcdf04fd40dffed6466d9fc1962f7c80f Mon Sep 17 00:00:00 2001 From: Rei Date: Wed, 13 Nov 2019 23:46:03 -0500 Subject: [PATCH] add common file extensions for gfpak export --- SPICA.WinForms/FrmMain.cs | 2 +- SPICA/Formats/GFLX/GFLXPack.cs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/SPICA.WinForms/FrmMain.cs b/SPICA.WinForms/FrmMain.cs index a003a5e3..d7515b09 100644 --- a/SPICA.WinForms/FrmMain.cs +++ b/SPICA.WinForms/FrmMain.cs @@ -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(); diff --git a/SPICA/Formats/GFLX/GFLXPack.cs b/SPICA/Formats/GFLX/GFLXPack.cs index fe4628c8..e8b96720 100644 --- a/SPICA/Formats/GFLX/GFLXPack.cs +++ b/SPICA/Formats/GFLX/GFLXPack.cs @@ -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); } }