diff --git a/SevenZip.Tests/MiscellaneousTests.cs b/SevenZip.Tests/MiscellaneousTests.cs index f99d4fb..4248aa5 100644 --- a/SevenZip.Tests/MiscellaneousTests.cs +++ b/SevenZip.Tests/MiscellaneousTests.cs @@ -32,18 +32,15 @@ public void SerializationTest() [Test] public void CreateSfxArchiveTest() { - Assert.Ignore("Legacy bug, needs investigation."); - var sfxFile = Path.Combine(OutputDirectory, "sfx.exe"); var sfx = new SevenZipSfx(); - var compressor = new SevenZipCompressor(); - using (var ms = new MemoryStream()) - { - compressor.CompressFiles(ms, @"TestData\zip.zip"); - sfx.MakeSfx(ms, sfxFile); - } + var compressor = new SevenZipCompressor {DirectoryStructure = false}; + + compressor.CompressFiles(TemporaryFile, @"TestData\zip.zip"); + + sfx.MakeSfx(TemporaryFile, sfxFile); Assert.IsTrue(File.Exists(sfxFile)); diff --git a/SevenZip.Tests/TestBase.cs b/SevenZip.Tests/TestBase.cs index 276d95b..f5ff62f 100644 --- a/SevenZip.Tests/TestBase.cs +++ b/SevenZip.Tests/TestBase.cs @@ -1,6 +1,7 @@ namespace SevenZip.Tests { using System.IO; + using System.Threading; using NUnit.Framework; @@ -20,7 +21,19 @@ public void SetUp() [TearDown] public void TearDown() { - Directory.Delete(OutputDirectory, true); + // Sometimes the Sfx test locks the .exe file for a few milliseconds. + for (var n = 0; n < 10; n++) + { + try + { + Directory.Delete(OutputDirectory, true); + break; + } + catch + { + Thread.Sleep(20); + } + } } } } diff --git a/SevenZip/SevenZip.csproj b/SevenZip/SevenZip.csproj index 95846ab..a8ca41c 100644 --- a/SevenZip/SevenZip.csproj +++ b/SevenZip/SevenZip.csproj @@ -121,8 +121,8 @@ - - + + @@ -138,10 +138,10 @@ - - - - + + + + @@ -156,14 +156,14 @@ - - - - - - - - + + + + + + + + diff --git a/SevenZip/SevenZipSfx.cs b/SevenZip/SevenZipSfx.cs index 08b11b8..dd1d0f5 100644 --- a/SevenZip/SevenZipSfx.cs +++ b/SevenZip/SevenZipSfx.cs @@ -44,17 +44,30 @@ public enum SfxModule /// public class SevenZipSfx { - private static readonly Dictionary> SfxSupportedModuleNames = - new Dictionary>(3) + private static Dictionary> SfxSupportedModuleNames + { + get { - {SfxModule.Default, new List(1) {"7zxSD_All.sfx"}}, - {SfxModule.Simple, new List(2) {"7z.sfx", "7zCon.sfx"}}, - {SfxModule.Installer, new List(2) {"7zS.sfx", "7zSD.sfx"}}, + var result = new Dictionary>(3) { - SfxModule.Extended, - new List(4) {"7zxSD_All.sfx", "7zxSD_Deflate", "7zxSD_LZMA", "7zxSD_PPMd"} - } - }; + {SfxModule.Simple, new List(2) {"7z.sfx", "7zCon.sfx"}}, + {SfxModule.Installer, new List(2) {"7zS.sfx", "7zSD.sfx"}} + }; + + if (Environment.Is64BitProcess) + { + result.Add(SfxModule.Default, new List(1) { "7zxSD_All_x64.sfx" }); + result.Add(SfxModule.Extended, new List(4) { "7zxSD_All_x64.sfx", "7zxSD_Deflate_x64", "7zxSD_LZMA_x64", "7zxSD_PPMd_x64" }); + } + else + { + result.Add(SfxModule.Default, new List(1) { "7zxSD_All.sfx" }); + result.Add(SfxModule.Extended, new List(4) { "7zxSD_All.sfx", "7zxSD_Deflate", "7zxSD_LZMA", "7zxSD_PPMd" }); + } + + return result; + } + } private SfxModule _module = SfxModule.Default; private string _moduleFileName; @@ -395,21 +408,19 @@ public void MakeSfx(Stream archive, SfxSettings settings, Stream sfxStream) ValidateSettings(settings); - using (Stream sfx = _module == SfxModule.Default - ? Assembly.GetExecutingAssembly().GetManifestResourceStream( - GetResourceString(SfxSupportedModuleNames[_module][0])) - : new FileStream(_moduleFileName, FileMode.Open, FileAccess.Read, - FileShare.ReadWrite)) + using (var sfx = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetResourceString(SfxSupportedModuleNames[_module][0]))) { WriteStream(sfx, sfxStream); } + if (_module == SfxModule.Custom || _sfxCommands[_module] != null) { - using (Stream set = GetSettingsStream(settings)) + using (var set = GetSettingsStream(settings)) { WriteStream(set, sfxStream); } } + WriteStream(archive, sfxStream); } diff --git a/readme.md b/readme.md index abda56d..3fec625 100644 --- a/readme.md +++ b/readme.md @@ -11,9 +11,6 @@ This is a fork from [tomap's fork](https://github.com/tomap/SevenZipSharp) of th Issues, suggestions, and Pull Requests are welcome! -## Known issues: -* Self-extracting archives cannot be created. - ------------------------------------------------------------- Original project information below, some information might be outdated or won't apply to this fork: