示例#1
0
        public void SkipRemainingChunk()
        {
            ChunkInfo current = mOpenChunks.Peek();

            byte[] buffer = new byte[256];
            while (current.Remaining > 0)
            {
                int block = (int)Math.Min(current.Remaining, 256U);
                int count = mStream.Read(buffer, 0, block);
                if (count != block)
                {
                    throw new Exception(string.Format("Need {0} bytes but only got {0}", block, count));
                }
                current.Consume((ulong)count);
            }
            mOpenChunks.Pop();
        }
示例#2
0
 public void OpenChunk(ChunkType type, ulong length)
 {
     if (mOpenChunks.Count() > 0)
     {
         ChunkInfo current = mOpenChunks.Peek();
         current.SetContainsSubChunks();
         current.Consume(length + 16);
     }
     mOpenChunks.Push(new ChunkInfo(type, length));
     byte[] bytes;
     bytes = BitConverter.GetBytes((ulong)type);
     if (BitConverter.IsLittleEndian)
         bytes.Reverse();
     mStream.Write(bytes, 0, 8);     // write ChunkType ASCII value
     bytes = BitConverter.GetBytes(length);
     if (BitConverter.IsLittleEndian)
         bytes.Reverse();
     mStream.Write(bytes, 0, 8);     // write length
 }