Skip to content

Commit

Permalink
Release 0.9.3.2
Browse files Browse the repository at this point in the history
Added solution for use between multiple sites/apps simultaneously; also
added GZip compression to reduce the assembly size by over half
  • Loading branch information
tuespetre committed Apr 28, 2014
1 parent 3a78cf0 commit 527e8a0
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 19 deletions.
6 changes: 2 additions & 4 deletions Pechkin/Pechkin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="wkhtmltox_64.dll" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="wkhtmltox_32.dll" />
<None Include="wkhtmltox_32.dll.gz" />
<None Include="wkhtmltox_64.dll.gz" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
Expand Down
20 changes: 16 additions & 4 deletions Pechkin/PechkinBindings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.InteropServices;
using Pechkin.Properties;
Expand All @@ -12,7 +13,7 @@ internal static class PechkinBindings
{
static PechkinBindings()
{
var raw = (IntPtr.Size == 8) ? Resources.wkhtmltox_64 : Resources.wkhtmltox_32;
var raw = (IntPtr.Size == 8) ? Resources.wkhtmltox_64_dll : Resources.wkhtmltox_32_dll;

SetupUnmanagedAssembly("wkhtmltox.dll", raw);
}
Expand Down Expand Up @@ -127,10 +128,11 @@ private static void SetupUnmanagedAssembly(string fileName, byte[] assemblyRaw)
var basePath = Path.Combine(
Path.GetTempPath(),
String.Format(
"{0}{1}_{2}",
"{0}{1}_{2}_{3}",
assemblyName.Name.ToString(),
assemblyName.Version.ToString(),
IntPtr.Size == 8 ? "x64" : "x86"));
IntPtr.Size == 8 ? "x64" : "x86",
String.Join(String.Empty, AppDomain.CurrentDomain.BaseDirectory.Split(Path.GetInvalidFileNameChars()))));

if (!Directory.Exists(basePath))
{
Expand All @@ -141,7 +143,17 @@ private static void SetupUnmanagedAssembly(string fileName, byte[] assemblyRaw)

if (!File.Exists(fileName))
{
File.WriteAllBytes(fileName, assemblyRaw);
var decompressed = new GZipStream(new MemoryStream(assemblyRaw), CompressionMode.Decompress);
var writeBuffer = new byte[8192];
var writeLength = 0;

using (var newFile = File.Open(fileName, FileMode.Create))
{
while((writeLength = decompressed.Read(writeBuffer, 0, writeBuffer.Length)) > 0)
{
newFile.Write(writeBuffer, 0, writeLength);
}
}
}

WinApiHelper.LoadLibrary(fileName);
Expand Down
4 changes: 2 additions & 2 deletions Pechkin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// 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("0.9.3.1")]
[assembly: AssemblyFileVersion("0.9.3.1")]
[assembly: AssemblyVersion("0.9.3.2")]
[assembly: AssemblyFileVersion("0.9.3.2")]
10 changes: 5 additions & 5 deletions Pechkin/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Pechkin/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="wkhtmltox_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\wkhtmltox_32.dll;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="wkhtmltox_32_dll" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\wkhtmltox_32.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="wkhtmltox_64" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\wkhtmltox_64.dll;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="wkhtmltox_64_dll" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\wkhtmltox_64.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
Binary file removed Pechkin/wkhtmltox_32.dll
Binary file not shown.
Binary file added Pechkin/wkhtmltox_32.dll.gz
Binary file not shown.
Binary file removed Pechkin/wkhtmltox_64.dll
Binary file not shown.
Binary file added Pechkin/wkhtmltox_64.dll.gz
Binary file not shown.

0 comments on commit 527e8a0

Please sign in to comment.