Exemplo n.º 1
0
        protected void ArchiveStreamReadExtractAll(IEnumerable <string> testArchives, CompressionType compression)
        {
            foreach (var path in testArchives)
            {
                ResetScratch();
                using (Stream stream = File.OpenRead(path))
                    using (var archive = ArchiveFactory.Open(stream))
                    {
                        Assert.IsTrue(archive.IsSolid);
                        using (var reader = archive.ExtractAllEntries())
                        {
                            ReaderTests.UseReader(this, reader, compression);
                        }
                        VerifyFiles();

                        if (archive.Entries.First().CompressionType == CompressionType.Rar)
                        {
                            return;
                        }
                        foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                        {
                            entry.WriteToDirectory(SCRATCH_FILES_PATH,
                                                   ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
                        }
                    }
                VerifyFiles();
            }
        }
Exemplo n.º 2
0
        protected void ArchiveStreamReadExtractAll(IEnumerable <string> testArchives, CompressionType compression)
        {
            foreach (var path in testArchives)
            {
                ResetScratch();
                using (var stream = new NonDisposingStream(File.OpenRead(path), true))
                    using (var archive = ArchiveFactory.Open(stream))
                    {
                        Assert.True(archive.IsSolid);
                        using (var reader = archive.ExtractAllEntries())
                        {
                            ReaderTests.UseReader(this, reader, compression);
                        }
                        VerifyFiles();

                        if (archive.Entries.First().CompressionType == CompressionType.Rar)
                        {
                            stream.ThrowOnDispose = false;
                            return;
                        }
                        foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
                        {
                            entry.WriteToDirectory(SCRATCH_FILES_PATH,
                                                   new ExtractionOptions
                            {
                                ExtractFullPath = true,
                                Overwrite       = true
                            });
                        }
                        stream.ThrowOnDispose = false;
                    }
                VerifyFiles();
            }
        }