Пример #1
0
        /// <summary>
        /// read block of compressed data
        /// </summary>
        /// <param name="block">compressed data</param>
        /// <returns>true if success</returns>
        public bool ReadData(out Block block)
        {
            if (inputStream.BaseStream.Position != inputStream.BaseStream.Length)
            {
                try
                {
                    block        = BlockPool.GetBlock();
                    block.Number = inputStream.ReadInt32();
                    int blockSize = inputStream.ReadInt32();
                    block.Data = inputStream.ReadBytes(blockSize);

                    //if (block.Data.Length != blockSize) throw new Exception("data block length doesn't match");
                    return(true);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            else
            {
                block = null;
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// read original data from input stream
 /// </summary>
 /// <param name="block">data converted to block</param>
 /// <returns>true if success</returns>
 public bool ReadData(out Block block)
 {
     if (inputStream.BaseStream.Position != inputStream.BaseStream.Length)
     {
         block        = BlockPool.GetBlock();
         block.Data   = inputStream.ReadBytes(blockSize);
         block.Number = counter++;
         return(true);
     }
     else
     {
         block = null;
         return(false);
     }
 }