Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void ExtractXenobladeARC(byte[] data, string arcname)
- {
- int count = BitConverter.ToInt32(data, 0x4);
- int stringtableofs = BitConverter.ToInt32(data, 0xC);
- if (count < 1) return;
- string outdir = Path.GetDirectoryName(arcname) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(arcname) + "_" + Path.DirectorySeparatorChar;
- for (int i = 0; i < count; i++)
- {
- Tuple<int, int> offset_size = Tuple.Create(BitConverter.ToInt32(data, 0x18 + 0x10 * i), BitConverter.ToInt32(data, 0x1C + 0x10 * i));
- byte[] fdata = new byte[offset_size.Item2];
- string filename;
- if (stringtableofs > 0)
- filename = new string(data.Skip((int)(stringtableofs + BitConverter.ToUInt32(data, (int)(stringtableofs + i * 0x4)))).TakeWhile(b => b != 0).Select(b => (char)b).ToArray());
- else
- filename = "arc/" + i.ToString("0000") + ".bin";
- string fileout = filename.Replace("arc/", outdir).Replace("/", String.Empty + Path.DirectorySeparatorChar);
- if (!Directory.Exists(Path.GetDirectoryName(fileout)))
- Directory.CreateDirectory(Path.GetDirectoryName(fileout));
- using (var fs = File.OpenRead(arcname))
- {
- fs.Seek(offset_size.Item1, SeekOrigin.Begin);
- fs.Read(fdata, 0, fdata.Length);
- fs.Close();
- }
- File.WriteAllBytes(fileout, fdata);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement