Rename the mobile_static profile to aot_only
[mono.git] / mcs / class / System / System.IO.Compression / DeflateStream.cs
index 726edf3f113d85c896d61baed29ac51517286656..a79f8826a9b324e615078aa3d10958c16d3ec965 100644 (file)
@@ -35,10 +35,6 @@ using System.IO;
 using System.Runtime.InteropServices;
 using System.Runtime.Remoting.Messaging;
 
-#if MONOTOUCH
-using MonoTouch;
-#endif
-
 namespace System.IO.Compression
 {
        public class DeflateStream : Stream
@@ -52,13 +48,13 @@ namespace System.IO.Compression
                bool disposed;
                DeflateStreamNative native;
 
-               public DeflateStream (Stream compressedStream, CompressionMode mode) :
-                       this (compressedStream, mode, false, false)
+               public DeflateStream (Stream stream, CompressionMode mode) :
+                       this (stream, mode, false, false)
                {
                }
 
-               public DeflateStream (Stream compressedStream, CompressionMode mode, bool leaveOpen) :
-                       this (compressedStream, mode, leaveOpen, false)
+               public DeflateStream (Stream stream, CompressionMode mode, bool leaveOpen) :
+                       this (stream, mode, leaveOpen, false)
                {
                }
 
@@ -80,7 +76,6 @@ namespace System.IO.Compression
                        this.leaveOpen = leaveOpen;
                }
                
-#if NET_4_5
                public DeflateStream (Stream stream, CompressionLevel compressionLevel)
                        : this (stream, compressionLevel, false, false)
                {
@@ -95,7 +90,6 @@ namespace System.IO.Compression
                        : this (stream, CompressionMode.Compress, leaveOpen, gzip)
                {
                }               
-#endif
 
                protected override void Dispose (bool disposing)
                {
@@ -126,23 +120,23 @@ namespace System.IO.Compression
                        }
                }
 
-               public override int Read (byte[] dest, int dest_offset, int count)
+               public override int Read (byte[] array, int offset, int count)
                {
                        if (disposed)
                                throw new ObjectDisposedException (GetType ().FullName);
-                       if (dest == null)
+                       if (array == null)
                                throw new ArgumentNullException ("Destination array is null.");
                        if (!CanRead)
                                throw new InvalidOperationException ("Stream does not support reading.");
-                       int len = dest.Length;
-                       if (dest_offset < 0 || count < 0)
+                       int len = array.Length;
+                       if (offset < 0 || count < 0)
                                throw new ArgumentException ("Dest or count is negative.");
-                       if (dest_offset > len)
+                       if (offset > len)
                                throw new ArgumentException ("destination offset is beyond array size");
-                       if ((dest_offset + count) > len)
+                       if ((offset + count) > len)
                                throw new ArgumentException ("Reading would overrun buffer");
 
-                       return ReadInternal (dest, dest_offset, count);
+                       return ReadInternal (array, offset, count);
                }
 
                unsafe void WriteInternal (byte[] array, int offset, int count)
@@ -156,16 +150,16 @@ namespace System.IO.Compression
                        }
                }
 
-               public override void Write (byte[] src, int src_offset, int count)
+               public override void Write (byte[] array, int offset, int count)
                {
                        if (disposed)
                                throw new ObjectDisposedException (GetType ().FullName);
 
-                       if (src == null)
-                               throw new ArgumentNullException ("src");
+                       if (array == null)
+                               throw new ArgumentNullException ("array");
 
-                       if (src_offset < 0)
-                               throw new ArgumentOutOfRangeException ("src_offset");
+                       if (offset < 0)
+                               throw new ArgumentOutOfRangeException ("offset");
 
                        if (count < 0)
                                throw new ArgumentOutOfRangeException ("count");
@@ -173,7 +167,10 @@ namespace System.IO.Compression
                        if (!CanWrite)
                                throw new NotSupportedException ("Stream does not support writing");
 
-                       WriteInternal (src, src_offset, count);
+                       if (offset > array.Length - count)
+                               throw new ArgumentException ("Buffer too small. count/offset wrong.");
+
+                       WriteInternal (array, offset, count);
                }
 
                public override void Flush ()
@@ -382,8 +379,8 @@ namespace System.IO.Compression
                        CheckResult (res, "WriteInternal");
                }
 
-#if MONOTOUCH
-               [MonoPInvokeCallback (typeof (UnmanagedReadOrWrite))]
+#if MONOTOUCH || FULL_AOT_RUNTIME
+               [Mono.Util.MonoPInvokeCallback (typeof (UnmanagedReadOrWrite))]
 #endif
                static int UnmanagedRead (IntPtr buffer, int length, IntPtr data)
                {
@@ -407,8 +404,8 @@ namespace System.IO.Compression
                        return n;
                }
 
-#if MONOTOUCH
-               [MonoPInvokeCallback (typeof (UnmanagedReadOrWrite))]
+#if MONOTOUCH || FULL_AOT_RUNTIME
+               [Mono.Util.MonoPInvokeCallback (typeof (UnmanagedReadOrWrite))]
 #endif
                static int UnmanagedWrite (IntPtr buffer, int length, IntPtr data)
                {