Last active
December 15, 2015 12:09
-
-
Save jonpryor/5258463 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mcs/tools/mkbundle/mkbundle.cs b/mcs/tools/mkbundle/mkbundle.cs | |
index 945522b..77cc712 100644 | |
--- a/mcs/tools/mkbundle/mkbundle.cs | |
+++ b/mcs/tools/mkbundle/mkbundle.cs | |
@@ -14,10 +14,10 @@ using System.Xml; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using System.IO; | |
+using System.IO.Compression; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
-using Mono.Unix; | |
-using ICSharpCode.SharpZipLib.Zip.Compression.Streams; | |
+ | |
#if NET_4_5 | |
using System.Threading.Tasks; | |
@@ -291,12 +291,12 @@ class MakeBundle { | |
int n; | |
if (compress) { | |
MemoryStream ms = new MemoryStream (); | |
- DeflaterOutputStream deflate = new DeflaterOutputStream (ms); | |
+ GZipStream deflate = new GZipStream (ms, CompressionMode.Compress, leaveOpen:true); | |
while ((n = stream.Read (buffer, 0, buffer.Length)) != 0){ | |
deflate.Write (buffer, 0, n); | |
} | |
stream.Close (); | |
- deflate.Finish (); | |
+ deflate.Close (); | |
byte [] bytes = ms.GetBuffer (); | |
stream = new MemoryStream (bytes, 0, (int) ms.Length, false, false); | |
} | |
@@ -604,10 +604,10 @@ class MakeBundle { | |
return; | |
} | |
- IntPtr buf = UnixMarshal.AllocHeap(8192); | |
+ IntPtr buf = Marshal.AllocHGlobal (8192); | |
if (uname (buf) != 0){ | |
Console.WriteLine ("Warning: Unable to detect OS"); | |
- UnixMarshal.FreeHeap(buf); | |
+ Marshal.FreeHGlobal (buf); | |
return; | |
} | |
string os = Marshal.PtrToStringAnsi (buf); | |
@@ -615,7 +615,7 @@ class MakeBundle { | |
if (os == "Darwin") | |
style = "osx"; | |
- UnixMarshal.FreeHeap(buf); | |
+ Marshal.FreeHGlobal (buf); | |
} | |
static bool IsUnix { | |
diff --git a/mcs/tools/mkbundle/template_z.c b/mcs/tools/mkbundle/template_z.c | |
index 7aac318..7987f82 100644 | |
--- a/mcs/tools/mkbundle/template_z.c | |
+++ b/mcs/tools/mkbundle/template_z.c | |
@@ -13,7 +13,8 @@ my_inflate (const Byte *compr, uLong compr_len, Byte *uncompr, uLong uncompr_len | |
memset (&stream, 0, sizeof (z_stream)); | |
stream.next_in = (Byte *) compr; | |
stream.avail_in = (uInt) compr_len; | |
- err = inflateInit (&stream); | |
+ /* To decompress gzip format: http://stackoverflow.com/a/1838702/83444 */ | |
+ err = inflateInit2 (&stream, 16+MAX_WBITS); | |
if (err != Z_OK) | |
return 1; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment