dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/IO BinaryReader.cs,1.


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/IO BinaryReader.cs,1.4,1.5 BinaryWriter.cs,1.4,1.5 StreamReader.cs,1.7,1.8StreamWriter.cs,1.8,1.9
Date: Sat, 10 May 2003 13:27:14 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/IO
In directory subversions:/tmp/cvs-serv1651/runtime/System/IO

Modified Files:
        BinaryReader.cs BinaryWriter.cs StreamReader.cs 
        StreamWriter.cs 
Log Message:
Prevent automatic finalization from closing underlying streams , because
these might be used elsewhere


Index: BinaryReader.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/IO/BinaryReader.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** BinaryReader.cs     23 Apr 2003 05:39:49 -0000      1.4
--- BinaryReader.cs     10 May 2003 17:27:11 -0000      1.5
***************
*** 75,78 ****
--- 75,82 ----
        public virtual void Close()
                        {
+                               if(input != null)
+                               {
+                                       input.Close();
+                               }
                                Dispose(true);
                        }
***************
*** 89,93 ****
                                if(input != null)
                                {
-                                       input.Close();
                                        input = null;
                                }
--- 93,96 ----

Index: BinaryWriter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/IO/BinaryWriter.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** BinaryWriter.cs     24 Apr 2003 00:50:35 -0000      1.4
--- BinaryWriter.cs     10 May 2003 17:27:11 -0000      1.5
***************
*** 86,89 ****
--- 86,93 ----
        public virtual void Close()
                        {
+                               if(OutStream != null)
+                               {
+                                       OutStream.Close();
+                               }
                                Dispose(true);
                        }
***************
*** 100,104 ****
                                if(OutStream != null)
                                {
-                                       OutStream.Close();
                                        OutStream = null;
                                }
--- 104,107 ----

Index: StreamReader.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/IO/StreamReader.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** StreamReader.cs     23 Apr 2003 06:28:50 -0000      1.7
--- StreamReader.cs     10 May 2003 17:27:11 -0000      1.8
***************
*** 51,54 ****
--- 51,55 ----
        private int             outBufferLen;
        private bool            sawEOF;
+       private bool            streamOwner;
  
        // Constructors that are based on a stream.
***************
*** 102,105 ****
--- 103,107 ----
                                this.outBufferLen = 0;
                                this.sawEOF = false;
+                               this.streamOwner = false;
  
                                // Should we change encodings based on a byte 
order mark?
***************
*** 165,168 ****
--- 167,171 ----
                                this.outBufferLen = 0;
                                this.sawEOF = false;
+                               this.streamOwner = true;
  
                                // Should we change encodings based on a byte 
order mark?
***************
*** 218,221 ****
--- 221,228 ----
        public override void Close()
                        {
+                               if(stream != null)
+                               {
+                                       stream.Close();
+                               }
                                Dispose(true);
                        }
***************
*** 242,246 ****
                                if(stream != null)
                                {
!                                       stream.Close();
                                        stream = null;
                                }
--- 249,256 ----
                                if(stream != null)
                                {
!                                       if(this.streamOwner)
!                                       {
!                                               stream.Close();
!                                       }
                                        stream = null;
                                }
***************
*** 507,510 ****
--- 517,521 ----
                                get
                                {
+                                       this.streamOwner = false;
                                        return stream;
                                }

Index: StreamWriter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/IO/StreamWriter.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** StreamWriter.cs     9 Feb 2003 09:48:59 -0000       1.8
--- StreamWriter.cs     10 May 2003 17:27:11 -0000      1.9
***************
*** 48,51 ****
--- 48,52 ----
        private byte[]          outBuffer;
        private bool            autoFlush;
+       private bool            streamOwner;
  
        // Constructors that are based on a stream.
***************
*** 89,92 ****
--- 90,94 ----
                                        [encoding.GetMaxByteCount(bufferSize)];
                                this.autoFlush = false;
+                               this.streamOwner = false;
  
                                // Write the encoding's preamble.
***************
*** 142,145 ****
--- 144,148 ----
                                        [encoding.GetMaxByteCount(bufferSize)];
                                this.autoFlush = false;
+                               this.streamOwner = true;
  
                                // Write the encoding's preamble.
***************
*** 166,169 ****
--- 169,180 ----
        public override void Close()
                        {
+                               // Explicit close 
+                               if(stream != null)
+                               {
+                                       Convert(true);
+                                       stream.Flush();
+                                       stream.Close();
+                                       stream = null;
+                               }
                                Dispose(true);
                        }
***************
*** 176,180 ****
                                        Convert(true);
                                        stream.Flush();
!                                       stream.Close();
                                        stream = null;
                                }
--- 187,195 ----
                                        Convert(true);
                                        stream.Flush();
!                                       // Close only if stream is Owned 
exclusively
!                                       if(this.streamOwner)
!                                       {
!                                               stream.Close();
!                                       }
                                        stream = null;
                                }
***************
*** 333,336 ****
--- 348,352 ----
                                get
                                {
+                                       this.streamOwner=false;
                                        return stream;
                                }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]