示例#1
0
        public void DecoderStillWorksWhenReadingSlowFile(string original, bool high, int block)
        {
            original = Tools.FindFile($".corpus/{original}");

            var encoded = Path.GetTempFileName();
            var decoded = Path.GetTempFileName();

            try
            {
                TestedLZ4.Encode(original, encoded, high, block, Mem.K64);

                using (var source = LZ4Legacy.Decode(Tools.Slow(File.OpenRead(encoded))))
                    using (var target = File.Create(decoded))
                    {
                        var buffer = new byte[Mem.K64];
                        while (true)
                        {
                            var read = source.Read(buffer, 0, buffer.Length);
                            if (read == 0)
                            {
                                break;
                            }

                            target.Write(buffer, 0, read);
                        }
                    }

                Tools.SameFiles(original, decoded);
            }
            finally
            {
                File.Delete(encoded);
                File.Delete(decoded);
            }
        }
示例#2
0
        public static void Decode(string encoded, string decoded, int chunkSize)
        {
            using (var source = LZ4Legacy.Decode(File.OpenRead(encoded)))
                using (var target = File.Create(decoded))
                {
                    var buffer = new byte[chunkSize];
                    while (true)
                    {
                        var read = source.Read(buffer, 0, buffer.Length);
                        if (read == 0)
                        {
                            break;
                        }

                        target.Write(buffer, 0, read);
                    }
                }
        }