FSO.Files.Formats.IFF.Chunks.PIFF.Write C# (CSharp) Méthode

Write() public méthode

public Write ( IffFile iff, Stream stream ) : bool
iff IffFile
stream Stream
Résultat bool
        public override bool Write(IffFile iff, Stream stream)
        {
            using (var io = IoWriter.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                io.WriteUInt16(1);
                io.WriteVariableLengthPascalString(SourceIff);
                io.WriteUInt16((ushort)Entries.Length);
                foreach (var ent in Entries)
                {
                    io.WriteCString(ent.Type, 4);
                    io.WriteUInt16(ent.ChunkID);
                    io.WriteByte((byte)(ent.Delete ? 1 : 0));

                    if (!ent.Delete)
                    {
                        io.WriteVariableLengthPascalString(ent.ChunkLabel); //0 length means no replacement
                        io.WriteUInt16(ent.ChunkFlags);
                        io.WriteUInt16(ent.NewChunkID);
                        io.WriteUInt32(ent.NewDataSize);
                        io.WriteUInt32((uint)ent.Patches.Length);

                        uint lastOff = 0;
                        foreach (var p in ent.Patches)
                        {
                            io.WriteVarLen(p.Offset-lastOff);
                            lastOff = p.Offset;
                            io.WriteVarLen(p.Size);
                            io.WriteByte((byte)p.Mode);
                            if (p.Mode == PIFFPatchMode.Add) io.WriteBytes(p.Data);
                        }
                    }
                }
            }
            return true;
        }