2010-03-22 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Mon, 22 Mar 2010 11:53:14 +0000 (11:53 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Mon, 22 Mar 2010 11:53:14 +0000 (11:53 -0000)
* Directory.cs, DirectoryInfo.cs: Disble new NET_4_0 API used in
SL4 until we have elevated trust working correctly (since they
are *not* decorated as [SecurityCritical])

svn path=/trunk/mcs/; revision=153968

mcs/class/corlib/System.IO/ChangeLog
mcs/class/corlib/System.IO/Directory.cs
mcs/class/corlib/System.IO/DirectoryInfo.cs

index 06ae1b8a24fcb6141a4bba44707e4d1b93966716..ba6491d7a994cd62c0c9943b2ee46842db43cbfd 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-22  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Directory.cs, DirectoryInfo.cs: Disble new NET_4_0 API used in
+       SL4 until we have elevated trust working correctly (since they 
+       are *not* decorated as [SecurityCritical])
+
 2010-03-17 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * StreamReader.cs: if the detected encoding is different from the
index 30fb5885f82616dd3019481a1715b087a24406c4..e48d233a9747fd06cc65fb2434863ef57be6664b 100644 (file)
@@ -522,6 +522,14 @@ namespace System.IO
                        return result;
                }
 
+               internal static void ValidatePath (string path)
+               {
+#if MOONLIGHT
+                       // On Moonlight (SL4+) this is possible, with limitations, in "Elevated Trust"
+                       throw new SecurityException ("we're not ready to enable this SL4 feature yet");
+#endif
+               }
+
 #if NET_4_0 || MOONLIGHT
                public static string[] GetFileSystemEntries (string path, string searchPattern, SearchOption searchOption)
                {
@@ -540,6 +548,8 @@ namespace System.IO
                        if (searchOption != SearchOption.TopDirectoryOnly && searchOption != SearchOption.AllDirectories)
                                throw new ArgumentOutOfRangeException ("searchoption");
 
+                       ValidatePath (path);
+
                        bool stop;
                        string path_with_pattern = ValidateDirectoryListing (path, searchPattern, out stop);
                        if (stop){
index b15067462892fbd555f2e7e434d33fc33f3772d1..f8f1f4be845ae7d927a2d286fe6e8f6803ca36ea 100644 (file)
@@ -431,6 +431,8 @@ namespace System.IO {
                        MonoIOError error;
                        FileAttributes rattr;
                        bool subdirs = searchOption == SearchOption.AllDirectories;
+
+                       Directory.ValidatePath (full); // required for Moonlight, nop-op otherwise
                        
                        string s = MonoIO.FindFirst (full, path_with_pattern, out rattr, out error, out handle);
                        if (s == null)