mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-19 21:23:17 +00:00
Conflicts: NuGet/sharpcompress.nuspec SharpCompress/VersionInfo.cs src/SharpCompress/Common/Tar/Headers/TarHeader.cs src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs src/SharpCompress/Compressor/BZip2/BZip2Stream.cs src/SharpCompress/Reader/ReaderFactory.cs src/SharpCompress/Writer/GZip/GZipWriter.cs src/SharpCompress/Writer/Tar/TarWriter.cs src/SharpCompress/Writer/WriterFactory.cs src/SharpCompress/Writer/Zip/ZipCentralDirectoryEntry.cs src/SharpCompress/Writer/Zip/ZipWriter.cs test/SharpCompress.Test/WriterTests.cs
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System;
|
|
using System.IO;
|
|
using SharpCompress.Common;
|
|
using SharpCompress.IO;
|
|
using SharpCompress.Reader;
|
|
using SharpCompress.Writer;
|
|
|
|
namespace SharpCompress.Test
|
|
{
|
|
public class WriterTests : TestBase
|
|
{
|
|
private ArchiveType type;
|
|
|
|
protected WriterTests(ArchiveType type)
|
|
{
|
|
this.type = type;
|
|
}
|
|
|
|
protected void Write(CompressionType compressionType, string archive, string archiveToVerifyAgainst)
|
|
{
|
|
ResetScratch();
|
|
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH2_FILES_PATH, archive)))
|
|
{
|
|
using (var writer = WriterFactory.Open(stream, type, compressionType, true))
|
|
{
|
|
writer.WriteAll(ORIGINAL_FILES_PATH, "*", SearchOption.AllDirectories);
|
|
}
|
|
if (!stream.CanWrite)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
}
|
|
CompareArchivesByPath(Path.Combine(SCRATCH2_FILES_PATH, archive),
|
|
Path.Combine(TEST_ARCHIVES_PATH, archiveToVerifyAgainst));
|
|
|
|
using (Stream stream = File.OpenRead(Path.Combine(SCRATCH2_FILES_PATH, archive)))
|
|
using (var reader = ReaderFactory.Open(stream))
|
|
{
|
|
reader.WriteAllToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath);
|
|
}
|
|
VerifyFiles();
|
|
}
|
|
}
|
|
}
|