Skip to content

Commit

Permalink
Fixed extraction of embedded files by using "using{}"
Browse files Browse the repository at this point in the history
  • Loading branch information
TXAE committed Mar 12, 2022
1 parent da7c528 commit 37b0acf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
8 changes: 5 additions & 3 deletions Interrupts_8086.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<Nullable>enable</Nullable>
<ApplicationIcon>Interrupts_8086.ico</ApplicationIcon>
<DebugType>embedded</DebugType>
<SignAssembly>False</SignAssembly>
<SignAssembly>True</SignAssembly>
<Authors>Daniel Hermes</Authors>
<Company>Tesla Automation || DHBW Mannheim</Company>
<PackageProjectUrl>https://github.com/TXAE/Interrupts_8086</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/TXAE/Interrupts_8086</RepositoryUrl>
<PackageTags>Digital</PackageTags>
<Description>Simulates interrupt handling of the Intel 8086 chip within Digital.
Builds on previous work by Silas Gerhard.</Description>
<Description>Simulates interrupt handling of the Intel 8086 chip within Digital</Description>
<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -29,6 +29,7 @@ Builds on previous work by Silas Gerhard.</Description>
<None Remove="Resources\Interruptcontroller.dig" />
<None Remove="Resources\IPCS.dig" />
<None Remove="Resources\ISR.dig" />
<None Remove="Resources\IVT.hex" />
<None Remove="Resources\Main_Interruptverarbeitung_8086.dig" />
<None Remove="Resources\Misc.dig" />
<None Remove="Resources\Offsetadd.dig" />
Expand All @@ -47,6 +48,7 @@ Builds on previous work by Silas Gerhard.</Description>
<EmbeddedResource Include="Resources\Interruptcontroller.dig" />
<EmbeddedResource Include="Resources\IPCS.dig" />
<EmbeddedResource Include="Resources\ISR.dig" />
<EmbeddedResource Include="Resources\IVT.hex" />
<EmbeddedResource Include="Resources\Main_Interruptverarbeitung_8086.dig" />
<EmbeddedResource Include="Resources\Misc.dig" />
<EmbeddedResource Include="Resources\Offsetadd.dig" />
Expand Down
21 changes: 14 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
Directory.CreateDirectory("Embedded_Circuits");

//extract assemblies
string[] assemblyNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
foreach (string assemblyName in assemblyNames)
string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
foreach (string resourceName in resourceNames)
{
if (assemblyName.Contains("Properties")) continue;
var assembly = Assembly.GetExecutingAssembly().GetManifestResourceStream(assemblyName);
string fileName = assemblyName.Replace("Interrupts_8086.Resources.", "");
var file = new FileStream("Embedded_Circuits\\" + fileName, FileMode.Create, FileAccess.Write);
assembly.CopyTo(file);
if (resourceName.Contains("Properties")) continue;

//has to be using! Will not work on some seemingly random files without using!
using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{
string fileName = resourceName.Replace("Interrupts_8086.Resources.", "");
using (var file = new FileStream("Embedded_Circuits\\" + fileName, FileMode.Create, FileAccess.Write))
{
resource.CopyTo(file);
}
}

}

Console.Write("Java Version: ");
Expand Down

0 comments on commit 37b0acf

Please sign in to comment.