RESOURCE_FILES = $(OTHER_RES)
-LOCAL_MCS_FLAGS=-r:Mono.Posix.dll -r:ICSharpCode.SharpZipLib.dll \
- $(OTHER_RES:%=-resource:%)
+LOCAL_MCS_FLAGS= $(OTHER_RES:%=-resource:%)
EXTRA_DISTFILES = $(RESOURCE_FILES)
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;
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);
}
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);
if (os == "Darwin")
style = "osx";
- UnixMarshal.FreeHeap(buf);
+ Marshal.FreeHGlobal (buf);
}
static bool IsUnix {
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;