From 0acbb11e97fd2fd16d3baf09c7da0a5dc4b7a845 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 27 Oct 2013 22:07:40 +0000 Subject: [PATCH] move HawkFile to BizHawk.Common along with a small web of dependencies and then add "using BizHawk.Common" to 100 files --- .../BizHawk.Client.Common.csproj | 2 +- BizHawk.Client.Common/RomGame.cs | 1 + .../SevenZipSharpArchiveHandler.cs | 63 +++ BizHawk.Client.Common/XmlGame.cs | 2 + BizHawk.Client.Common/movie/InputAdapters.cs | 2 + BizHawk.Client.Common/movie/MovieImport.cs | 2 +- BizHawk.Common/BizHawk.Common.csproj | 6 + BizHawk.Common/Extensions.cs | 457 +++++++++++++++++ .../HawkFile.cs | 139 ++---- BizHawk.Common/Types.cs | 31 ++ BizHawk.Common/Util.cs | 11 + BizHawk.Emulation/CPUs/68000/OpcodeTable.cs | 2 + BizHawk.Emulation/CPUs/HuC6280/HuC6280.cs | 2 + BizHawk.Emulation/CPUs/MOS 6502X/Execute.cs | 3 + .../Computers/Commodore64/SaveState.cs | 2 + BizHawk.Emulation/Consoles/Calculator/TI83.cs | 2 + .../Consoles/Coleco/ColecoVision.cs | 2 + BizHawk.Emulation/Consoles/Coleco/TMS9918A.cs | 2 + .../Consoles/Nintendo/GBA/Meteor.cs | 2 + .../Consoles/Nintendo/Gameboy/Gambatte.cs | 2 + .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 2 + .../Consoles/Nintendo/N64/N64.cs | 2 + .../Consoles/Nintendo/NES/APU.cs | 1 + .../Nintendo/NES/Boards/BANDAI-FCG-1.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Camerica.cs | 4 +- .../Nintendo/NES/Boards/JALECO_JF_05_06_07.cs | 4 +- .../Nintendo/NES/Boards/JALECO_JF_19.cs | 4 +- .../Nintendo/NES/Boards/MLT-ACTION52.cs | 4 +- .../Consoles/Nintendo/NES/Boards/MLT-MAX15.cs | 4 +- .../Nintendo/NES/Boards/MMC3_family/HKROM.cs | 2 + .../Nintendo/NES/Boards/MMC3_family/MMC3.cs | 1 + .../NES/Boards/MMC3_family/Mapper049.cs | 4 +- .../NES/Boards/MMC3_family/Mapper052.cs | 4 +- .../NES/Boards/MMC3_family/Mapper115.cs | 4 +- .../NES/Boards/MMC3_family/Mapper191.cs | 2 + .../NES/Boards/MMC3_family/Mapper245.cs | 4 +- .../NES/Boards/MMC3_family/Mapper249.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper015.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper045.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper057.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper058.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper069.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper078.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper090.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper116.cs | 2 + .../Consoles/Nintendo/NES/Boards/Mapper176.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper178.cs | 5 +- .../Consoles/Nintendo/NES/Boards/Mapper200.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper207.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper225.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper226.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper227.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper230.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper231.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper233.cs | 5 +- .../Consoles/Nintendo/NES/Boards/Mapper242.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper50.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper61.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Mapper62.cs | 4 +- .../Nintendo/NES/Boards/NAMCOT_m19_m210.cs | 4 +- .../Consoles/Nintendo/NES/Boards/NES-EVENT.cs | 4 +- .../NES/Boards/Namcot1xx/Mapper154.cs | 4 +- .../Nintendo/NES/Boards/PxROM_FxROM.cs | 4 +- .../Consoles/Nintendo/NES/Boards/SEEPROM.cs | 2 + .../Nintendo/NES/Boards/Sunsoft2_m89.cs | 4 +- .../Nintendo/NES/Boards/Sunsoft2_m93.cs | 4 +- .../Consoles/Nintendo/NES/Boards/Sunsoft3.cs | 4 +- .../NES/Boards/TAITO_74_161_161_32.cs | 4 +- .../Nintendo/NES/Boards/TENGEN-800032.cs | 4 +- .../Nintendo/NES/Boards/Taito_X1_005.cs | 4 +- .../Nintendo/NES/Boards/Taito_X1_017.cs | 4 +- .../Consoles/Nintendo/NES/Boards/VRC1.cs | 4 +- .../Consoles/Nintendo/NES/Boards/VRC2_4.cs | 2 + .../Consoles/Nintendo/NES/Boards/VRC3.cs | 4 +- .../Consoles/Nintendo/NES/Boards/VRC6.cs | 2 + .../Consoles/Nintendo/NES/Boards/VRC7.cs | 2 + .../Consoles/Nintendo/NES/PPU.regs.cs | 1 + .../Consoles/Nintendo/SNES/LibsnesCore.cs | 2 + BizHawk.Emulation/Consoles/PC Engine/ADPCM.cs | 2 + .../Consoles/PC Engine/ArcadeCard.cs | 2 + .../Consoles/PC Engine/PCEngine.cs | 2 + .../Consoles/PC Engine/ScsiCDBus.cs | 2 + BizHawk.Emulation/Consoles/PC Engine/VCE.cs | 2 + BizHawk.Emulation/Consoles/PC Engine/VDC.cs | 2 + BizHawk.Emulation/Consoles/PC Engine/VPC.cs | 2 + .../Consoles/Sega/Genesis/GenVDP.cs | 2 + .../Consoles/Sega/Genesis/Genesis.cs | 5 +- BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs | 2 + BizHawk.Emulation/Consoles/Sega/SMS/VDP.cs | 3 + .../Consoles/Sega/Saturn/Yabause.cs | 2 + .../DiscSystem/Blobs/Blob_ECM.cs | 2 + BizHawk.Emulation/Sound/HuC6280PSG.cs | 2 + BizHawk.Emulation/Sound/MMC5Audio.cs | 2 + BizHawk.Emulation/Sound/Sunsoft5BAudio.cs | 2 + BizHawk.Emulation/Sound/VRC6Alt.cs | 2 + BizHawk.Emulation/Util.cs | 472 +----------------- BizHawk.MultiClient/AVOut/WavWriter.cs | 2 + BizHawk.MultiClient/ArchiveChooser.cs | 1 + BizHawk.MultiClient/MainForm.cs | 1 + BizHawk.MultiClient/Program.cs | 3 + BizHawk.MultiClient/movie/PlayMovie.cs | 1 + BizHawk.MultiClient/tools/GB/GBGPUView.cs | 1 + BizHawk.MultiClient/tools/GBA/GBAGPUView.cs | 1 + .../tools/HexEditor/HexEditor.cs | 1 + .../tools/NES/NESGraphicsConfig.cs | 1 + .../tools/SNES/SNESGraphicsDebugger.cs | 1 + 106 files changed, 853 insertions(+), 610 deletions(-) create mode 100644 BizHawk.Client.Common/SevenZipSharpArchiveHandler.cs create mode 100644 BizHawk.Common/Extensions.cs rename {BizHawk.Client.Common => BizHawk.Common}/HawkFile.cs (85%) create mode 100644 BizHawk.Common/Types.cs create mode 100644 BizHawk.Common/Util.cs 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 @@ + + + +