protected override void Routine()
 {
     while (!_synchronizer.HasDataToRead())
     {
         byte[] buffer = _synchronizer.GetData(out _blockIndex);
         if (buffer == null)
         {
             continue;
         }
         buffer = Compress(buffer);
         if (buffer.Length == 0)
         {
             buffer = GZipFileMember.GetDefaultHeader();
         }
         GZipFileMember.WriteMemberSizeToExtraField(ref buffer);
         _synchronizer.WriteData(_blockIndex, buffer);
     }
 }
示例#2
0
 private void ReadFile()
 {
     using (FileStream sourceStream = new FileStream(_sourceFile, FileMode.Open)) {
         while (sourceStream.Position != sourceStream.Length)
         {
             byte[] extendedHeader = new byte[20];
             sourceStream.Read(extendedHeader, 0, extendedHeader.Length);
             if (!GZipFileMember.IsGzipFormat(extendedHeader))
             {
                 throw new FileFormatException("Not Gzip member file!");
             }
             int memberSize = GZipFileMember.GetMemberSize(extendedHeader);
             if (memberSize == 0)
             {
                 _readData.Add(new byte[0]);
             }
             Array.Resize <byte>(ref extendedHeader, memberSize);
             sourceStream.Read(extendedHeader, 20, memberSize - 20);
             _readData.Add(extendedHeader);
         }
     }
     _readData.CompleteAdding();
 }