Beispiel #1
0
        public void WriteChunkHeader(FileChunkHeader header)
        {
            Check.IfArgumentNull(header, "header");

            var stream = this.CurrentStream;

            if (Object.ReferenceEquals(header.DataStream, stream))
            {
                throw new ArgumentException("Specified header is still on the stack.", "header");
            }

            // write chunk header
            header.ChunkId.WriteTo(stream);

            // data length
            this.numberWriter.WriteInt32(header.DataStream.Position, stream);

            // write chunk body
            header.DataStream.Position = 0;
            header.DataStream.CopyTo(stream);

            // optionally align each chunk
            if (this.streamNavigator != null)
            {
                this.streamNavigator.AlignPosition(stream);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Pushes a new initialized header onto the stack.
        /// </summary>
        /// <param name="chunkId">Must not be null.</param>
        /// <returns>Returns the header object. Never returns null.</returns>
        private FileChunkHeader PushNewHeader(FourCharacterCode chunkId)
        {
            var header = new FileChunkHeader();

            header.DataStream = new MemoryStream();
            header.ChunkId    = chunkId;

            this.context.HeaderStack.Push(header);

            return(header);
        }