diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index f1e25e819b..dcfddc065c 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -95,7 +95,6 @@ - @@ -114,6 +113,7 @@ + diff --git a/BizHawk.Client.Common/RomGame.cs b/BizHawk.Client.Common/RomGame.cs index eb43355584..b92dfbc315 100644 --- a/BizHawk.Client.Common/RomGame.cs +++ b/BizHawk.Client.Common/RomGame.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; +using BizHawk.Common; using BizHawk.Client.Common; namespace BizHawk.MultiClient diff --git a/BizHawk.Client.Common/SevenZipSharpArchiveHandler.cs b/BizHawk.Client.Common/SevenZipSharpArchiveHandler.cs new file mode 100644 index 0000000000..a55ea832bd --- /dev/null +++ b/BizHawk.Client.Common/SevenZipSharpArchiveHandler.cs @@ -0,0 +1,63 @@ +using System; +using System.IO; +using System.Collections.Generic; + +using BizHawk.Common; + +namespace BizHawk.Client.Common +{ + /// + /// Implementation of IHawkFileArchiveHandler using SevenZipSharp pure managed code + /// + public class SevenZipSharpArchiveHandler : IHawkFileArchiveHandler + { + public void Dispose() + { + if (extractor != null) + { + extractor.Dispose(); + extractor = null; + } + } + + public bool CheckSignature(string fileName, out int offset, out bool isExecutable) + { + SevenZip.FileChecker.ThrowExceptions = false; + return SevenZip.FileChecker.CheckSignature(fileName, out offset, out isExecutable) != SevenZip.InArchiveFormat.None; + } + + public IHawkFileArchiveHandler Construct(string path) + { + SevenZipSharpArchiveHandler ret = new SevenZipSharpArchiveHandler(); + ret.Open(path); + return ret; + } + + void Open(string path) + { + extractor = new SevenZip.SevenZipExtractor(path); + } + + SevenZip.SevenZipExtractor extractor; + + public List Scan() + { + List ret = new List(); + for (int i = 0; i < extractor.ArchiveFileData.Count; i++) + { + var afd = extractor.ArchiveFileData[i]; + if (afd.IsDirectory) continue; + var ai = new HawkFileArchiveItem { name = HawkFile.Util_FixArchiveFilename(afd.FileName), size = (long)afd.Size, archiveIndex = i, index = ret.Count }; + ret.Add(ai); + } + + return ret; + } + + public void ExtractFile(int index, Stream stream) + { + extractor.ExtractFile(index, stream); + } + } + +} \ No newline at end of file diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs index 707b1e3b4e..3305856bac 100644 --- a/BizHawk.Client.Common/XmlGame.cs +++ b/BizHawk.Client.Common/XmlGame.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Xml; +using BizHawk.Common; + namespace BizHawk.Client.Common { public class XmlGame diff --git a/BizHawk.Client.Common/movie/InputAdapters.cs b/BizHawk.Client.Common/movie/InputAdapters.cs index e1022473ed..815f387753 100644 --- a/BizHawk.Client.Common/movie/InputAdapters.cs +++ b/BizHawk.Client.Common/movie/InputAdapters.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using BizHawk.Common; + namespace BizHawk.Client.Common { /// diff --git a/BizHawk.Client.Common/movie/MovieImport.cs b/BizHawk.Client.Common/movie/MovieImport.cs index 74316fd672..e91a6359cd 100644 --- a/BizHawk.Client.Common/movie/MovieImport.cs +++ b/BizHawk.Client.Common/movie/MovieImport.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.IO; -#pragma warning disable 219 +using BizHawk.Common; namespace BizHawk.Client.Common { diff --git a/BizHawk.Common/BizHawk.Common.csproj b/BizHawk.Common/BizHawk.Common.csproj index 15497a6fd8..6c4a82917e 100644 --- a/BizHawk.Common/BizHawk.Common.csproj +++ b/BizHawk.Common/BizHawk.Common.csproj @@ -22,6 +22,7 @@ prompt 4 AnyCPU + true pdbonly @@ -31,6 +32,7 @@ prompt 4 AnyCPU + true @@ -42,9 +44,13 @@ + + + +