You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.88
Former-commit-id: 4b7216ffda08448e562271ce733688e761120fc5
This commit is contained in:
parent
7d05485754
commit
6123a772ed
@@ -322,7 +322,7 @@ namespace System.IO.Compression
|
||||
UnmanagedReadOrWrite feeder; // This will be passed to unmanaged code and used there
|
||||
|
||||
Stream base_stream;
|
||||
IntPtr z_stream;
|
||||
SafeDeflateStreamHandle z_stream;
|
||||
GCHandle data;
|
||||
bool disposed;
|
||||
byte [] io_buffer;
|
||||
@@ -337,7 +337,7 @@ namespace System.IO.Compression
|
||||
dsn.data = GCHandle.Alloc (dsn);
|
||||
dsn.feeder = mode == CompressionMode.Compress ? new UnmanagedReadOrWrite (UnmanagedWrite) : new UnmanagedReadOrWrite (UnmanagedRead);
|
||||
dsn.z_stream = CreateZStream (mode, gzip, dsn.feeder, GCHandle.ToIntPtr (dsn.data));
|
||||
if (dsn.z_stream == IntPtr.Zero) {
|
||||
if (dsn.z_stream.IsInvalid) {
|
||||
dsn.Dispose (true);
|
||||
return null;
|
||||
}
|
||||
@@ -359,10 +359,7 @@ namespace System.IO.Compression
|
||||
|
||||
io_buffer = null;
|
||||
|
||||
IntPtr zz = z_stream;
|
||||
z_stream = IntPtr.Zero;
|
||||
if (zz != IntPtr.Zero)
|
||||
CloseZStream (zz); // This will Flush() the remaining output if any
|
||||
z_stream.Dispose();
|
||||
}
|
||||
|
||||
if (data.IsAllocated) {
|
||||
@@ -488,21 +485,21 @@ namespace System.IO.Compression
|
||||
|
||||
#if !ORBIS
|
||||
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data);
|
||||
static extern SafeDeflateStreamHandle CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data);
|
||||
|
||||
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int CloseZStream (IntPtr stream);
|
||||
|
||||
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int Flush (IntPtr stream);
|
||||
static extern int Flush (SafeDeflateStreamHandle stream);
|
||||
|
||||
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int ReadZStream (IntPtr stream, IntPtr buffer, int length);
|
||||
static extern int ReadZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length);
|
||||
|
||||
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
|
||||
static extern int WriteZStream (IntPtr stream, IntPtr buffer, int length);
|
||||
static extern int WriteZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length);
|
||||
#else
|
||||
static IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data)
|
||||
static SafeDeflateStreamHandle CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data)
|
||||
{
|
||||
throw new PlatformNotSupportedException ();
|
||||
}
|
||||
@@ -512,22 +509,39 @@ namespace System.IO.Compression
|
||||
throw new PlatformNotSupportedException ();
|
||||
}
|
||||
|
||||
static int Flush (IntPtr stream)
|
||||
static int Flush (SafeDeflateStreamHandle stream)
|
||||
{
|
||||
throw new PlatformNotSupportedException ();
|
||||
}
|
||||
|
||||
static int ReadZStream (IntPtr stream, IntPtr buffer, int length)
|
||||
static int ReadZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length)
|
||||
{
|
||||
throw new PlatformNotSupportedException ();
|
||||
}
|
||||
|
||||
static int WriteZStream (IntPtr stream, IntPtr buffer, int length)
|
||||
static int WriteZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length)
|
||||
{
|
||||
throw new PlatformNotSupportedException ();
|
||||
}
|
||||
#endif
|
||||
|
||||
sealed class SafeDeflateStreamHandle : SafeHandle
|
||||
{
|
||||
public override bool IsInvalid
|
||||
{
|
||||
get { return handle == IntPtr.Zero; }
|
||||
}
|
||||
|
||||
private SafeDeflateStreamHandle() : base(IntPtr.Zero, true)
|
||||
{
|
||||
}
|
||||
|
||||
override protected bool ReleaseHandle()
|
||||
{
|
||||
DeflateStreamNative.CloseZStream(handle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user