diff --git a/demo/build.cake b/demo/build.cake index aabb8ae2..338d46f2 100644 --- a/demo/build.cake +++ b/demo/build.cake @@ -167,6 +167,18 @@ Task("RenameFile") .WithRenameFile(File("CODE_OF_CONDUCT.md"), File("CODE_OF_CONDUCT.txt"))); }); +Task("GH78") + .IsDependentOn("Clean") + .IsDependentOn("ZipVolumes") + .Does(() => +{ + SevenZip(m => m + .InExtractMode() + .WithArchive(output + File("volume.7z.001")) + .WithArchiveType(SwitchArchiveType.SevenZip.Volumes()) + .WithOutputDirectory(output + Directory("Test01"))); +}); + Task("Default") .IsDependentOn("Clean") .IsDependentOn("ZipIt") @@ -179,6 +191,7 @@ Task("Default") .IsDependentOn("GetHash") .IsDependentOn("DoBenchmark") .IsDependentOn("ListArchiveContent") - .IsDependentOn("RenameFile"); + .IsDependentOn("RenameFile") + .IsDependentOn("GH78"); RunTarget(target); \ No newline at end of file diff --git a/src/Cake.7zip.Tests/Settings/Switches/SwitchArchiveTypeTests.cs b/src/Cake.7zip.Tests/Settings/Switches/SwitchArchiveTypeTests.cs index 87e0d150..ba20ae51 100644 --- a/src/Cake.7zip.Tests/Settings/Switches/SwitchArchiveTypeTests.cs +++ b/src/Cake.7zip.Tests/Settings/Switches/SwitchArchiveTypeTests.cs @@ -24,6 +24,18 @@ public void ArchiveType_StaticProps_works(SwitchArchiveType type, string expecte actual.Should().Be(expected); } + [Theory] + [ClassData(typeof(TestData))] + public void ArchiveType_StaticPropsSplit_works(SwitchArchiveType type, string expectedType) + { + var fixture = new SevenZipSettingsFixture(); + var expected = "-t" + expectedType + ".split"; + + var actual = fixture.Parse(b => type.Volumes().BuildArguments(ref b)); + + actual.Should().Be(expected); + } + private class TestData : IEnumerable { public IEnumerator GetEnumerator() diff --git a/src/Cake.7zip/Builder/ExtractCommandBuilder.cs b/src/Cake.7zip/Builder/ExtractCommandBuilder.cs index 30cb2f7d..d5295db7 100644 --- a/src/Cake.7zip/Builder/ExtractCommandBuilder.cs +++ b/src/Cake.7zip/Builder/ExtractCommandBuilder.cs @@ -20,6 +20,16 @@ namespace Cake.SevenZip.Builder /// .WithArchiveType(SwitchArchiveType.Zip) /// .WithOutputDirectory("some/other/directory")); /// }); + /// + /// Task("UnzipVolumes") + /// .Does(() => + /// { + /// SevenZip(m => m + /// .InExtractMode() + /// .WithArchive(File("path/to/file.7z.001")) + /// .WithArchiveType(SwitchArchiveType.SevenZip.Volumes()) + /// .WithOutputDirectory("some/other/directory")); + /// }); /// ]]> /// /// diff --git a/src/Cake.7zip/Switches/SwitchArchiveType.cs b/src/Cake.7zip/Switches/SwitchArchiveType.cs index 2fe1fed8..197a65ad 100644 --- a/src/Cake.7zip/Switches/SwitchArchiveType.cs +++ b/src/Cake.7zip/Switches/SwitchArchiveType.cs @@ -74,6 +74,16 @@ private SwitchArchiveType(string type) /// public static SwitchArchiveType Bzip2 { get; } = new SwitchArchiveType("bzip2"); + /// + /// Append ".split" to the type. + /// This is needed when extracting/testing multi-volume archives. + /// + /// A with .split appended. + public SwitchArchiveType Volumes() + { + return new SwitchArchiveType(type + ".split"); + } + /// public void BuildArguments(ref ProcessArgumentBuilder builder) {