[asp.net] Ignore directories that don't exist instead of throwing.
[mono.git] / mcs / class / System.Web / System.Web.Util / FileUtils.cs
index 2467ca037183a12c67aea06a2f54f5ef5e0a8037..15afddaaeae82030d76b11eea2519a1a8eb88f21 100644 (file)
@@ -29,6 +29,7 @@
 //
 
 using System;
+using System.Diagnostics;
 using System.Globalization;
 using System.IO;
 
@@ -57,7 +58,6 @@ namespace System.Web.Util
                        if (createFile == null)
                                return null;
                        string path = null;
-                       bool done = false;
                        object ret = null;
                        int num;
                        
@@ -68,7 +68,7 @@ namespace System.Web.Util
 
                                 path = Path.Combine (tempdir,
                                                     String.Format ("{0}{1}{2}", (prefix != null) ? prefix + "." : "",
-                                                                   num.ToString ("x", CultureInfo.InvariantCulture),
+                                                                   num.ToString ("x", Helpers.InvariantCulture),
                                                                    (extension != null) ? "." + extension : ""));
                                         
                                 try {
@@ -79,5 +79,24 @@ namespace System.Web.Util
 
                        return ret;
                }
+
+               [Conditional ("DEVEL")]
+               public static void WriteLineLog (string logFilePath, string format, params object[] parms)
+               {
+                       WriteLog (logFilePath, format + Environment.NewLine, parms);
+               }
+               
+               [Conditional ("DEVEL")]
+               public static void WriteLog (string logFilePath, string format, params object[] parms)
+               {
+                       string path = logFilePath != null && logFilePath.Length > 0 ? logFilePath :
+                               Path.Combine (Path.GetTempPath (), "System.Web.log");
+                       using (TextWriter tw = new StreamWriter (path, true)) {
+                               if (parms != null && parms.Length > 0)
+                                       tw.Write (format, parms);
+                               else
+                                       tw.Write (format);
+                       }
+               }
        }
 }