FSO.Files.Formats.IFF.Chunks.GLOB.Read C# (CSharp) Method

Read() public method

Reads a GLOB chunk from a stream.
public Read ( IffFile iff, Stream stream ) : void
iff IffFile An Iff instance.
stream Stream A Stream object holding a GLOB chunk.
return void
        public override void Read(IffFile iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                StringBuilder temp = new StringBuilder();
                var num = io.ReadByte();
                if (num < 48)
                { //less than smallest ASCII value for valid filename character, so assume this is a pascal string
                    temp.Append(io.ReadCString(num));
                }
                else
                { //we're actually a null terminated string!
                    temp.Append((char)num);
                    while (stream.Position < stream.Length)
                    {
                        char read = (char)io.ReadByte();
                        if (read == 0) break;
                        else temp.Append(read);
                    }
                }
                Name = temp.ToString();
            }
        }