Merge pull request #4845 from lambdageek/dev-coop-delegates
[mono.git] / mcs / class / corlib / System / TimeZoneInfo.cs
index 7a12080c6a89b822ca68d4806c861d4785655836..1c5cdd3ae820dc363687a19efbfe553ca31b6b20 100644 (file)
@@ -152,7 +152,7 @@ namespace System
 #if !MONODROID && !MONOTOUCH && !XAMMAC
                static TimeZoneInfo CreateLocal ()
                {
-#if !FULL_AOT_DESKTOP || WIN_PLATFORM
+#if WIN_PLATFORM
                        if (IsWindows && LocalZoneKey != null) {
                                string name = (string)LocalZoneKey.GetValue ("TimeZoneKeyName");
                                if (name == null)
@@ -206,7 +206,7 @@ namespace System
 
                static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
                {
-#if !FULL_AOT_DESKTOP || WIN_PLATFORM
+#if WIN_PLATFORM
                        if (TimeZoneKey != null) {
                                foreach (string id in TimeZoneKey.GetSubKeyNames ()) {
                                        try {
@@ -278,7 +278,7 @@ namespace System
 #endif
                private AdjustmentRule [] adjustmentRules;
 
-#if !MOBILE || !FULL_AOT_DESKTOP || WIN_PLATFORM
+#if (!MOBILE || !FULL_AOT_DESKTOP || WIN_PLATFORM) && !XAMMAC_4_5
                /// <summary>
                /// Determine whether windows of not (taken Stephane Delcroix's code)
                /// </summary>
@@ -305,7 +305,7 @@ namespace System
                        
                        return str.Substring (Istart, Iend-Istart+1);
                }
-               
+
 #if !FULL_AOT_DESKTOP || WIN_PLATFORM
                static RegistryKey timeZoneKey;
                static RegistryKey TimeZoneKey {
@@ -574,11 +574,17 @@ namespace System
 #if LIBC
                private static TimeZoneInfo FindSystemTimeZoneByFileName (string id, string filepath)
                {
-                       if (!File.Exists (filepath))
-                               throw new TimeZoneNotFoundException ();
-
-                       using (FileStream stream = File.OpenRead (filepath)) {
+                       FileStream stream = null;
+                       try {
+                               stream = File.OpenRead (filepath);      
+                       } catch (Exception ex) {
+                               throw new TimeZoneNotFoundException ("Couldn't read time zone file " + filepath, ex);
+                       }
+                       try {
                                return BuildFromStream (id, stream);
+                       } finally {
+                               if (stream != null)
+                                       stream.Dispose();
                        }
                }
 #endif