public void Pack(string file) { Files = null; FT = false; string[] files = Directory.GetFiles(file); Files = new FARCFile[files.Length]; for (int i = 0; i < files.Length; i++) { Files[i] = new FARCFile { Name = files[i] }; string ext = Path.GetExtension(files[i]).ToLower(); if (ext == ".a3da" || ext == ".mot" || ext == ".vag") { Signature = Farc.FArc; } } files = null; KKtIO writer = KKtIO.OpenWriter(file + ".farc", true); if (Signature == Farc.FArc) { writer.Write(Text.ToASCII("FArc")); } else if (Signature == Farc.FArC) { writer.Write(Text.ToASCII("FArC")); } else { writer.Write(Text.ToASCII("FARC")); } KKtIO HeaderWriter = new KKtIO(new MemoryStream()); for (int i = 0; i < 3; i++) { HeaderWriter.Write((byte)0x00); } if (Signature == Farc.FArc) { HeaderWriter.Write((byte)0x20); } else if (Signature == Farc.FArC) { HeaderWriter.Write((byte)0x10); } else if (Signature == Farc.FARC) { HeaderWriter.Write((byte)0x06); for (int i = 0; i < 7; i++) { HeaderWriter.Write((byte)0x00); } HeaderWriter.Write((byte)0x40); for (int i = 0; i < 8; i++) { HeaderWriter.Write((byte)0x00); } } for (int i = 0; i < Files.Length; i++) { for (int i1 = 0; i1 < Path.GetFileName(Files[i].Name).Length + (Signature == Farc.FArc ? 0x09 : 0x0D); i1++) { HeaderWriter.Write((byte)0x00); } } writer.WriteEndian((uint)HeaderWriter.Length, true); writer.Write(HeaderWriter.ToArray()); HeaderWriter = null; int Align = (int)Main.Align(writer.Position, 0x10) - (int)writer.Position; for (int i1 = 0; i1 < Align; i1++) { if (Signature == Farc.FArc) { writer.Write((byte)0x00); } else { writer.Write((byte)0x78); } } for (int i = 0; i < Files.Length; i++) { CompressStuff(i, ref Files, ref writer); } if (Signature == Farc.FARC) { writer.Seek(0x1C, 0); } else { writer.Seek(0x0C, 0); } for (int i = 0; i < Files.Length; i++) { writer.Write(Text.ToUTF8(Path.GetFileName(Files[i].Name) + "\0")); writer.WriteEndian(Files[i].Offset, true); if (Signature != Farc.FArc) { writer.WriteEndian(Files[i].SizeComp, true); } writer.WriteEndian(Files[i].SizeUnc, true); } writer.Close(); }