Skip to content

Commit

Permalink
Merge pull request #2 from kaeedo/bugfix/emptyIlCode
Browse files Browse the repository at this point in the history
Fix zip handling on Linux
  • Loading branch information
Kai authored Jan 7, 2017
2 parents c6eb31a + 02322fa commit deb2a8d
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ Cursed.userprefs
/Cursed.Base.Tests/bin/Release
/Cursed.Base.Tests/obj/Release
/TestResult.xml
Cursed*.zip
Cursed*.zip
/Unzip/bin/Debug
/Unzip/obj
4 changes: 2 additions & 2 deletions Cursed.Base/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace System
open System.Reflection

[<assembly: AssemblyVersionAttribute("1.2.1")>]
[<assembly: AssemblyVersionAttribute("1.2.2")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyVersion = "1.2.1"
let [<Literal>] AssemblyVersion = "1.2.2"
19 changes: 12 additions & 7 deletions Cursed.Base/Cursed.Base.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Unzip\Unzip.csproj">
<Name>Unzip</Name>
<Project>{086e3b87-5bd8-4e62-a640-723ce384dc3c}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="..\.paket\paket.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.0'">
Expand Down Expand Up @@ -152,6 +157,11 @@
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
<ItemGroup>
<Reference Include="Hopac">
<HintPath>..\packages\Hopac\lib\net45\Hopac.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Hopac.Core">
<HintPath>..\packages\Hopac\lib\net45\Hopac.Core.dll</HintPath>
<Private>True</Private>
Expand All @@ -162,11 +172,6 @@
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Hopac">
<HintPath>..\packages\Hopac\lib\net45\Hopac.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
Expand Down
6 changes: 4 additions & 2 deletions Cursed.Base/ModpackController.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

open System
open System.IO
open System.IO.Compression
open Common
open Hopac
open HttpFs.Client

open Unzip

module ModpackController =
let CreateMultiMcInstance version name author forge =
[ "InstanceType", "OneSix"
Expand Down Expand Up @@ -35,7 +36,8 @@ module ModpackController =
let ExtractZip location ((zipName: string), (zipLocation: string)) =
let modpackSubdirectory = zipName.Substring(0, zipName.LastIndexOf('.'))
let extractLocation = location @@ modpackSubdirectory @@ "minecraft"
ZipFile.ExtractToDirectory(zipLocation @@ zipName, extractLocation)

Zip.ExtractZipFile(zipLocation @@ zipName, extractLocation)

let fileInfo = new FileInfo(zipLocation @@ zipName)
fileInfo.Delete()
Expand Down
2 changes: 1 addition & 1 deletion Cursed.Base/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Eto.Forms
FSharp.Data
FSharp.Core
Http.fs
Newtonsoft.Json
Newtonsoft.Json
6 changes: 6 additions & 0 deletions Cursed.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Cursed.Base", "Cursed.Base\
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Cursed.Base.Tests", "Cursed.Base.Tests\Cursed.Base.Tests.fsproj", "{3431D878-1CA7-4C9F-8FFC-552F4CDD1075}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unzip", "Unzip\Unzip.csproj", "{086E3B87-5BD8-4E62-A640-723CE384DC3C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -42,6 +44,10 @@ Global
{3431D878-1CA7-4C9F-8FFC-552F4CDD1075}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3431D878-1CA7-4C9F-8FFC-552F4CDD1075}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3431D878-1CA7-4C9F-8FFC-552F4CDD1075}.Release|Any CPU.Build.0 = Release|Any CPU
{086E3B87-5BD8-4E62-A640-723CE384DC3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{086E3B87-5BD8-4E62-A640-723CE384DC3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{086E3B87-5BD8-4E62-A640-723CE384DC3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{086E3B87-5BD8-4E62-A640-723CE384DC3C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions Cursed/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace System
open System.Reflection

[<assembly: AssemblyVersionAttribute("1.2.1")>]
[<assembly: AssemblyVersionAttribute("1.2.2")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyVersion = "1.2.1"
let [<Literal>] AssemblyVersion = "1.2.2"
16 changes: 5 additions & 11 deletions Cursed/Cursed.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@
<Reference Include="System.Core">
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression">
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression.FileSystem">
<Private>True</Private>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime">
<Private>True</Private>
Expand Down Expand Up @@ -224,6 +218,11 @@
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
<ItemGroup>
<Reference Include="Hopac">
<HintPath>..\packages\Hopac\lib\net45\Hopac.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Hopac.Core">
<HintPath>..\packages\Hopac\lib\net45\Hopac.Core.dll</HintPath>
<Private>True</Private>
Expand All @@ -234,11 +233,6 @@
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Hopac">
<HintPath>..\packages\Hopac\lib\net45\Hopac.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
Expand Down
36 changes: 36 additions & 0 deletions Unzip/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Unzip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Unzip")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("086e3b87-5bd8-4e62-a640-723ce384dc3c")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
95 changes: 95 additions & 0 deletions Unzip/Unzip.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{086E3B87-5BD8-4E62-A640-723CE384DC3C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Unzip</RootNamespace>
<AssemblyName>Unzip</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Zip.cs" />
</ItemGroup>
<ItemGroup>
<None Include="paket.references" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v1.1'">
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\packages\SharpZipLib\lib\11\ICSharpCode.SharpZipLib.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v3.0' Or $(TargetFrameworkVersion) == 'v3.5' Or $(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\packages\SharpZipLib\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == 'Silverlight' And $(TargetFrameworkVersion) == 'v3.0'">
<ItemGroup>
<Reference Include="SharpZipLib.Silverlight3">
<HintPath>..\packages\SharpZipLib\lib\SL3\SharpZipLib.Silverlight3.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == 'Silverlight' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v5.0')">
<ItemGroup>
<Reference Include="SharpZipLib.Silverlight4">
<HintPath>..\packages\SharpZipLib\lib\SL4\SharpZipLib.Silverlight4.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
57 changes: 57 additions & 0 deletions Unzip/Zip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;

namespace Unzip
{
public static class Zip
{
public static void ExtractZipFile(string archiveFilenameIn, string outFolder)
{
ZipFile zf = null;
try
{
FileStream fs = File.OpenRead(archiveFilenameIn);
zf = new ZipFile(fs);

foreach (ZipEntry zipEntry in zf)
{
if (!zipEntry.IsFile)
{
continue; // Ignore directories
}
String entryFileName = zipEntry.Name;
// to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
// Optionally match entrynames against a selection list here to skip as desired.
// The unpacked length is available in the zipEntry.Size property.

byte[] buffer = new byte[4096]; // 4K is optimum
Stream zipStream = zf.GetInputStream(zipEntry);

// Manipulate the output filename here as desired.
String fullZipToPath = Path.Combine(outFolder, entryFileName);
string directoryName = Path.GetDirectoryName(fullZipToPath);
if (directoryName.Length > 0)
Directory.CreateDirectory(directoryName);

// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
// of the file, but does not waste memory.
// The "using" will close the stream even if an exception occurs.
using (FileStream streamWriter = File.Create(fullZipToPath))
{
StreamUtils.Copy(zipStream, streamWriter, buffer);
}
}
}
finally
{
if (zf != null)
{
zf.IsStreamOwner = true; // Makes close also shut the underlying stream
zf.Close(); // Ensure we release resources
}
}
}
}
}
1 change: 1 addition & 0 deletions Unzip/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SharpZipLib
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<title></title>
</head>
<body>
<input type="hidden" id="latestRelease" value="1.2.1" />
<input type="hidden" id="latestRelease" value="1.2.2" />
</body>
</html>
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ nuget FSharp.Data
nuget FSharp.Core redirects: force
nuget Http.fs
nuget Newtonsoft.Json
nuget SharpZipLib

nuget NUnit
nuget Unquote
Expand Down
1 change: 1 addition & 0 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ NUGET
NUnit.Extension.NUnitV2ResultWriter (3.5)
NUnit.Extension.TeamCityEventListener (1.0.2)
NUnit.Extension.VSProjectLoader (3.5)
SharpZipLib (0.86)
System.Collections (4.3) - framework: >= netstandard10
Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13
Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13
Expand Down
Loading

0 comments on commit deb2a8d

Please sign in to comment.