Author: kostat
Date: 2007-05-16 02:04:45 -0400 (Wed, 16 May 2007)
New Revision: 77450

Modified:
   trunk/mcs/class/System.XML/System.Xml/ChangeLog
   trunk/mcs/class/System.XML/System.Xml/XmlTextWriter2.cs
   trunk/mcs/class/System.XML/System.Xml/XmlWriter.cs
Log:
ensure the file is closed in XmlWriter.Create(filename)

Modified: trunk/mcs/class/System.XML/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/ChangeLog     2007-05-16 06:01:20 UTC 
(rev 77449)
+++ trunk/mcs/class/System.XML/System.Xml/ChangeLog     2007-05-16 06:04:45 UTC 
(rev 77450)
@@ -1,3 +1,8 @@
+2007-05-15  Konstantin Triger <[EMAIL PROTECTED]>
+
+       * XmlWriter.cs, XmlTextWriter2.cs: ensure the file
+               is closed in XmlWriter.Create(filename).
+
 2007-04-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XmlConvert.cs : MinValue and MaxValue, same for ToDateTime().

Modified: trunk/mcs/class/System.XML/System.Xml/XmlTextWriter2.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlTextWriter2.cs     2007-05-16 
06:01:20 UTC (rev 77449)
+++ trunk/mcs/class/System.XML/System.Xml/XmlTextWriter2.cs     2007-05-16 
06:04:45 UTC (rev 77450)
@@ -263,14 +263,14 @@
 
 #if NET_2_0
                internal XmlTextWriter (
-                       TextWriter writer, XmlWriterSettings settings)
+                       TextWriter writer, XmlWriterSettings settings, bool 
closeOutput)
                {
                        if (settings == null)
                                settings = new XmlWriterSettings ();
 
                        Initialize (writer);
 
-                       close_output_stream = settings.CloseOutput;
+                       close_output_stream = closeOutput;
                        allow_doc_fragment =
                                settings.ConformanceLevel != 
ConformanceLevel.Document;
                        switch (settings.ConformanceLevel) {

Modified: trunk/mcs/class/System.XML/System.Xml/XmlWriter.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlWriter.cs  2007-05-16 06:01:20 UTC 
(rev 77449)
+++ trunk/mcs/class/System.XML/System.Xml/XmlWriter.cs  2007-05-16 06:04:45 UTC 
(rev 77450)
@@ -125,7 +125,7 @@
                public static XmlWriter Create (string file, XmlWriterSettings 
settings)
                {
                        Encoding enc = settings != null ? settings.Encoding : 
Encoding.UTF8;
-                       return Create (new StreamWriter (file, false, enc), 
settings);
+                       return CreateTextWriter (new StreamWriter (file, false, 
enc), settings, true);
                }
 
                public static XmlWriter Create (StringBuilder builder, 
XmlWriterSettings settings)
@@ -135,7 +135,9 @@
 
                public static XmlWriter Create (TextWriter writer, 
XmlWriterSettings settings)
                {
-                       return CreateTextWriter (writer, settings);
+                       if (settings == null)
+                               settings = new XmlWriterSettings ();
+                       return CreateTextWriter (writer, settings, 
settings.CloseOutput);
                }
 
                public static XmlWriter Create (XmlWriter writer, 
XmlWriterSettings settings)
@@ -146,11 +148,11 @@
                        return writer;
                }
 
-               private static XmlWriter CreateTextWriter (TextWriter writer, 
XmlWriterSettings settings)
+               private static XmlWriter CreateTextWriter (TextWriter writer, 
XmlWriterSettings settings, bool closeOutput)
                {
                        if (settings == null)
                                settings = new XmlWriterSettings ();
-                       XmlTextWriter xtw = new XmlTextWriter (writer, 
settings);
+                       XmlTextWriter xtw = new XmlTextWriter (writer, 
settings, closeOutput);
                        return Create (xtw, settings);
                }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to