示例#1
0
        /// <summary>
        /// Closes the current archive stream, if necessary.
        /// </summary>
        private void CloseArchiveStream()
        {
            if (mArchiveStream != null)
            {
                long bytesToSkip = mArchiveStream.Length - mArchiveStream.Position;
                if (mStream.CanSeek)
                {
                    // stream supports seeking
                    // => set stream position
                    mStream.Position += bytesToSkip;
                }
                else
                {
                    // stream does not support seeking
                    // => read and discard bytes to skip
                    byte[] buffer = mSerializer.mTempBuffer_BigBuffer;
                    while (bytesToSkip > 0)
                    {
                        int bytesToRead = (int)Math.Min(bytesToSkip, int.MaxValue);
                        bytesToRead  = Math.Min(bytesToRead, buffer.Length);
                        bytesToSkip -= mStream.Read(buffer, 0, bytesToRead);
                    }
                }

                mArchiveStream.Dispose();
                mArchiveStream = null;
            }
        }
示例#2
0
 /// <summary>
 /// Closes the current archive stream, if necessary.
 /// </summary>
 private void CloseArchiveStream()
 {
     if (mArchiveStream != null)
     {
         mArchiveStream.Dispose();
         mArchiveStream = null;
     }
 }