Beispiel #1
0
        static void Exect(Stream read
                          , Stream write
                          , ReadWriteManager manager
                          , System.IO.Compression.CompressionMode mode
                          , int?readBufferSize, int tCount)
        {
            manager.CreateThreadPool(
                tCount
                , () => read.BeginRead(
                    manager.GetReadExectContext(
                        block => write.BeginWrite(
                            block.GZip(mode)
                            , manager.GetWriteExectContext()))
                    , readBufferSize))
            .ForEach(t => t.Start());

            long res = 0, old = 0;

            while (!manager.WaitOne(100))
            {
                if (old < (res = (100 * read.Position) / read.Length))
                {
                    Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " Прогресс: " + (old = res) + "%");
                }
            }

            manager.IsExceptionHappened();

            Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " Завершено за " + manager.TotalTime().ToString());
        }
Beispiel #2
0
        internal static byte[] Deflate(byte[] source_byte, System.IO.Compression.CompressionMode type_deflate)
        {
            byte[] dest_byte = null;

            using (System.IO.MemoryStream dest_mem = new System.IO.MemoryStream())
            {
                using (System.IO.MemoryStream source_mem = new System.IO.MemoryStream(source_byte))
                {
                    if (source_mem.CanSeek)
                    {
                        source_mem.Seek(0, System.IO.SeekOrigin.Begin);
                    }

                    if (type_deflate == System.IO.Compression.CompressionMode.Compress)
                    {
                        using (System.IO.Compression.DeflateStream deflate = new System.IO.Compression.DeflateStream(dest_mem, type_deflate))
                        {
                            source_mem.CopyTo(deflate);
                            deflate.Flush();
                        }
                    }
                    else
                    {
                        using (System.IO.Compression.DeflateStream deflate = new System.IO.Compression.DeflateStream(source_mem, type_deflate))
                        {
                            deflate.CopyTo(dest_mem);
                            deflate.Flush();
                        }
                    }

                    source_mem.Flush();
                }
                if (dest_mem.CanSeek)
                {
                    dest_mem.Seek(0, System.IO.SeekOrigin.Begin);
                }
                dest_byte = dest_mem.ToArray();
                dest_mem.Flush();
            }

            return(dest_byte);
        }
 public BrotliStream(System.IO.Stream stream, System.IO.Compression.CompressionMode mode, bool leaveOpen)
 {
 }
 public BrotliStream(System.IO.Stream stream, System.IO.Compression.CompressionMode mode)
 {
 }
Beispiel #5
0
 public DeflateStream(System.IO.Stream compressedStream, System.IO.Compression.CompressionMode mode, bool leaveOpen)
 {
 }
Beispiel #6
0
 public DeflateStream(System.IO.Stream compressedStream, System.IO.Compression.CompressionMode mode)
 {
 }
Beispiel #7
0
 public GZipStream(System.IO.Stream stream, System.IO.Compression.CompressionMode mode)
 {
 }
 public DeflateStream(System.IO.Stream stream, System.IO.Compression.CompressionMode mode, bool leaveOpen) => throw null;