コード例 #1
0
ファイル: FpkFile.cs プロジェクト: engrin/GzsTool
        public override void Write(Stream output, IDirectory inputDirectory)
        {
            BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true);
            const int headerSize = 48;
            int indicesSize = 48*Entries.Count;
            int referenceSize = 16*References.Count;

            long startPosition = output.Position;
            output.Position += headerSize + indicesSize + referenceSize;

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.WriteFilePath(output);
            }
            foreach (var fpkReference in References)
            {
                fpkReference.WriteFilePath(output);
            }
            output.AlignWrite(16, 0x00);

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.WriteData(output, inputDirectory);
                output.AlignWrite(16, 0x00);
            }

            uint fileSize = (uint) output.Position;

            output.Position = startPosition;

            writer.Write(0x66786f66); // foxf
            writer.Write((ushort) 0x6B70); //pk
            writer.Write((byte) FpkType);
            writer.Write((byte) 0x77); // w
            writer.Write((ushort) 0x6E69); // in
            writer.Write(fileSize);
            writer.WriteZeros(18);
            writer.Write(0x00000002);
            writer.Write(Entries.Count);
            writer.Write(References.Count);
            writer.WriteZeros(4);

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.Write(output);
            }
            foreach (var fpkReference in References)
            {
                fpkReference.Write(output);
            }
        }
コード例 #2
0
ファイル: FpkFile.cs プロジェクト: emoose/GzsTool
        public override void Write(Stream output, IDirectory inputDirectory)
        {
            X360Writer writer = new X360Writer(output, Encoding.Default, true, IsBigEndianPlatform(Platform));
            const int headerSize = 48;
            int indicesSize = 48*Entries.Count;
            int referenceSize = 16*References.Count;

            long startPosition = output.Position;
            output.Position += headerSize + indicesSize + referenceSize;

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.WriteFilePath(writer);
            }
            foreach (var fpkReference in References)
            {
                fpkReference.WriteFilePath(writer);
            }
            output.AlignWrite(16, 0x00);

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.WriteData(writer, inputDirectory);
                output.AlignWrite(16, 0x00);
            }

            uint fileSize = (uint) output.Position;

            output.Position = startPosition;

            if (writer.FlipEndian)
                writer.FlipEndian = false;
            writer.Write(0x66786f66); // foxf
            writer.Write((ushort) 0x6B70); //pk
            writer.Write((byte) FpkType);
            writer.WriteAsciiString(Platform, 3);
            writer.Write(fileSize);

            writer.FlipEndian = IsBigEndianPlatform(Platform);

            writer.WriteZeros(18);
            writer.Write(UnknownValue);
            writer.Write(Entries.Count);
            writer.Write(References.Count);
            writer.WriteZeros(4);

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.Write(writer);
            }
            foreach (var fpkReference in References)
            {
                fpkReference.Write(writer);
            }
        }