Merge pull request #844 from scottmcarthur/master
[mono.git] / mcs / class / System.Core / System.IO.Pipes / PipeStream.cs
index 6c516450e10fcaa02ff2d357a895b12d1ab859f0..fd4a57a693063f4b21c28f755bd953d42089206b 100644 (file)
@@ -25,6 +25,9 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+#if !BOOTSTRAP_BASIC
+
 using Microsoft.Win32.SafeHandles;
 using System;
 using System.IO;
@@ -32,6 +35,7 @@ using System.Linq;
 using System.Security.AccessControl;
 using System.Security.Permissions;
 using System.Security.Principal;
+using System.Runtime.InteropServices;
 
 namespace System.IO.Pipes
 {
@@ -101,7 +105,7 @@ namespace System.IO.Pipes
                PipeTransmissionMode transmission_mode, read_trans_mode;
                int buffer_size;
                SafePipeHandle handle;
-               FileStream stream;
+               Stream stream;
 
                public override bool CanRead {
                        get { return (direction & PipeDirection.In) != 0; }
@@ -123,14 +127,17 @@ namespace System.IO.Pipes
 
                public bool IsConnected { get; protected set; }
 
-               private Stream Stream {
+               internal Stream Stream {
                        get {
                                if (!IsConnected)
                                        throw new InvalidOperationException ("Pipe is not connected");
                                if (stream == null)
-                                       stream = new FileStream (handle.DangerousGetHandle (), CanRead ? (CanWrite ? FileAccess.ReadWrite : FileAccess.Read) : FileAccess.Write, true, buffer_size, IsAsync);
+                                       stream = new FileStream (handle.DangerousGetHandle (),
+                                                                CanRead ? (CanWrite ? FileAccess.ReadWrite : FileAccess.Read)
+                                                                        : FileAccess.Write, true, buffer_size, IsAsync);
                                return stream;
                        }
+                       set { stream = value; }
                }
 
                protected bool IsHandleExposed { get; private set; }
@@ -188,7 +195,7 @@ namespace System.IO.Pipes
                protected internal void CheckWriteOperations ()
                {
                        if (!IsConnected)
-                               throw new InvalidOperationException ("Pipe us not connected");
+                               throw new InvalidOperationException ("Pipe is not connected");
                        if (!CanWrite)
                                throw new NotSupportedException ("The pipe stream does not support write operations");
                }
@@ -227,16 +234,20 @@ namespace System.IO.Pipes
                        throw new NotSupportedException ();
                }
 
-               [MonoNotSupported ("ACL is not supported in Mono")]
                public PipeSecurity GetAccessControl ()
                {
-                       throw ThrowACLException ();
+                       return new PipeSecurity (SafePipeHandle,
+                                                AccessControlSections.Owner |
+                                                AccessControlSections.Group |
+                                                AccessControlSections.Access);
                }
 
-               [MonoNotSupported ("ACL is not supported in Mono")]
                public void SetAccessControl (PipeSecurity pipeSecurity)
                {
-                       throw ThrowACLException ();
+                       if (pipeSecurity == null)
+                               throw new ArgumentNullException ("pipeSecurity");
+                               
+                       pipeSecurity.Persist (SafePipeHandle);
                }
 
                // pipe I/O
@@ -246,7 +257,7 @@ namespace System.IO.Pipes
                }
 
                [MonoTODO]
-               public override int Read (byte [] buffer, int offset, int count)
+               public override int Read ([In] byte [] buffer, int offset, int count)
                {
                        CheckReadOperations ();
 
@@ -318,3 +329,5 @@ namespace System.IO.Pipes
                }
        }
 }
+
+#endif