2009-09-18 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 18 Sep 2009 15:57:32 +0000 (15:57 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 18 Sep 2009 15:57:32 +0000 (15:57 -0000)
* Directory.cs: Avoid imperative CAS checks and remove
AccessControl types for NET_2_1
* DirectoryInfo.cs: Remove AccessControl types for NET_2_1
* File.cs: Remove AccessControl types for NET_2_1
* FileInfo.cs: Remove AccessControl types for NET_2_1
* FileStream.cs: Remove AccessControl types for NET_2_1
* Path.cs: Avoid imperative CAS checks for NET_2_1

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

mcs/class/corlib/System.IO/ChangeLog
mcs/class/corlib/System.IO/Directory.cs
mcs/class/corlib/System.IO/DirectoryInfo.cs
mcs/class/corlib/System.IO/File.cs
mcs/class/corlib/System.IO/FileInfo.cs
mcs/class/corlib/System.IO/FileStream.cs
mcs/class/corlib/System.IO/Path.cs

index 036adab1ebb54ef7353e808feba8c40f16a5b0ef..e8215057aee95938f1bcc268e8cb9af3c27576f6 100644 (file)
@@ -1,3 +1,13 @@
+2009-09-18  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Directory.cs: Avoid imperative CAS checks and remove 
+       AccessControl types for NET_2_1
+       * DirectoryInfo.cs: Remove AccessControl types for NET_2_1
+       * File.cs: Remove AccessControl types for NET_2_1
+       * FileInfo.cs: Remove AccessControl types for NET_2_1
+       * FileStream.cs: Remove AccessControl types for NET_2_1
+       * Path.cs: Avoid imperative CAS checks for NET_2_1
+
 2009-09-17 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * DirectoryInfo.cs: throw if FullPath is not a directory.
index 899a7d3049c4035389bee8459171f0f4b4829757..a406113bd77752371cf3fe438018f3a90f88ae66 100644 (file)
@@ -42,8 +42,10 @@ using System.Collections;
 using System.Security;
 using System.Security.Permissions;
 using System.Text;
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
 using System.Security.AccessControl;
+#endif
+#if NET_2_0
 using System.Runtime.InteropServices;
 #endif
 
@@ -92,7 +94,7 @@ namespace System.IO
                        return CreateDirectoriesInternal (path);
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                [MonoTODO ("DirectorySecurity not implemented")]
                public static DirectoryInfo CreateDirectory (string path, DirectorySecurity directorySecurity)
                {
@@ -102,10 +104,11 @@ namespace System.IO
 
                static DirectoryInfo CreateDirectoriesInternal (string path)
                {
+#if !NET_2_1
                        if (SecurityManager.SecurityEnabled) {
                                new FileIOPermission (FileIOPermissionAccess.Read | FileIOPermissionAccess.Write, path).Demand ();
                        }
-
+#endif
                        DirectoryInfo info = new DirectoryInfo (path, true);
                        if (info.Parent != null && !info.Parent.Exists)
                                 info.Parent.Create ();
@@ -263,10 +266,11 @@ namespace System.IO
                        string result = MonoIO.GetCurrentDirectory (out error);
                        if (error != MonoIOError.ERROR_SUCCESS)
                                throw MonoIO.GetException (error);
-
+#if !NET_2_1
                        if ((result != null) && (result.Length > 0) && SecurityManager.SecurityEnabled) {
                                new FileIOPermission (FileIOPermissionAccess.PathDiscovery, result).Demand ();
                        }
+#endif
                        return result;
                }
                
@@ -408,7 +412,7 @@ namespace System.IO
                                throw MonoIO.GetException (error);
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                public static void SetAccessControl (string path, DirectorySecurity directorySecurity)
                {
                        throw new NotImplementedException ();
@@ -530,7 +534,7 @@ namespace System.IO
                        return result;
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                [MonoNotSupported ("DirectorySecurity isn't implemented")]
                public static DirectorySecurity GetAccessControl (string path, AccessControlSections includeSections)
                {
index 8ff428405864f69a58e41dfaa7ad473952300cac..681d57f7c4acbaad017aa51814661be707f1d6db 100644 (file)
@@ -35,7 +35,7 @@ using System.Collections;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Text;
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
 using System.Security.AccessControl;
 #endif
 
@@ -312,7 +312,7 @@ namespace System.IO {
                                throw new ArgumentOutOfRangeException ("searchOption", msg);
                        }
                }
-
+#if !NET_2_1
                // access control methods
 
                [MonoLimitation ("DirectorySecurity isn't implemented")]
@@ -350,6 +350,7 @@ namespace System.IO {
                                throw new ArgumentNullException ("directorySecurity");
                        throw new UnauthorizedAccessException ();
                }
+#endif
 #endif
        }
 }
index 2e7ca744342bd0575361e508837031a2dfd93c3c..17d5c91b2ef4e391589fee62efc2da1c6520f6cd 100644 (file)
@@ -37,6 +37,8 @@ using System.Text;
 #if NET_2_0
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
+#endif
+#if NET_2_0 && !NET_2_1
 using System.Security.AccessControl;
 #endif
 
@@ -125,15 +127,16 @@ namespace System.IO
 
                public static FileStream Create (string path)
                {
-                       return Create (path, 8192, FileOptions.None, null);
+                       return Create (path, 8192);
                }
 
                public static FileStream Create (string path, int bufferSize)
                {
-                       return Create (path, bufferSize, FileOptions.None, null);
+                       return new FileStream (path, FileMode.Create, FileAccess.ReadWrite,
+                               FileShare.None, bufferSize);
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                [MonoTODO ("options not implemented")]
                public static FileStream Create (string path, int bufferSize,
                                                 FileOptions options)
@@ -145,20 +148,11 @@ namespace System.IO
                public static FileStream Create (string path, int bufferSize,
                                                 FileOptions options,
                                                 FileSecurity fileSecurity)
-#else
-               private static FileStream Create (string path, int bufferSize,
-                                                 FileOptions options,
-                                                 object fileSecurity)
-#endif
                {
-#if NET_2_0
                        return new FileStream (path, FileMode.Create, FileAccess.ReadWrite,
                                FileShare.None, bufferSize, options);
-#else
-                       return new FileStream (path, FileMode.Create, FileAccess.ReadWrite,
-                               FileShare.None, bufferSize);
-#endif
                }
+#endif
 
                public static StreamWriter CreateText (string path)
                {
@@ -202,7 +196,7 @@ namespace System.IO
                        return MonoIO.ExistsFile (path, out error);
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                public static FileSecurity GetAccessControl (string path)
                {
                        throw new NotImplementedException ();
@@ -440,7 +434,8 @@ namespace System.IO
                                throw MonoIO.GetException (error);
                        }
                }
-               
+#endif
+#if NET_2_0 && !NET_2_1
                public static void SetAccessControl (string path,
                                                     FileSecurity fileSecurity)
                {
index 6dc3fe9baf30e1623648008d7d082d845c601bd8..a1e58e8a7855a0d4ef855fc89c71a33156376224 100644 (file)
@@ -36,7 +36,7 @@
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
 using System.Security.AccessControl;
 #endif
 
@@ -93,7 +93,7 @@ namespace System.IO {
                        }
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                public bool IsReadOnly {
                        get {
                                if (!Exists)
@@ -271,7 +271,7 @@ namespace System.IO {
 #endif
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                public FileSecurity GetAccessControl ()
                {
                        throw new NotImplementedException ();
index f9f3055fa421f368e6ad002cd5877e4651c62dab..6759f294f0f886cf0617b4abc31d6902ef23fa0c 100644 (file)
@@ -39,10 +39,11 @@ using System.Threading;
 
 #if NET_2_0
 using Microsoft.Win32.SafeHandles;
-using System.Security.AccessControl;
-#endif
 #if NET_2_1
 using System.IO.IsolatedStorage;
+#else
+using System.Security.AccessControl;
+#endif
 #endif
 
 namespace System.IO
@@ -141,7 +142,7 @@ namespace System.IO
                {
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                public FileStream (string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options)
                        : this (path, mode, access, share, bufferSize, false, options)
                {
@@ -939,7 +940,7 @@ namespace System.IO
                                GC.SuppressFinalize (this);
                }
 
-#if NET_2_0
+#if NET_2_0 && !NET_2_1
                public FileSecurity GetAccessControl ()
                {
                        throw new NotImplementedException ();
index b9ea9640aa5c8f1c842921911dbb936bb038a7a8..2887b80d4bbec8c3e3bc42832707418842e0b64a 100644 (file)
@@ -285,9 +285,11 @@ namespace System.IO {
                public static string GetFullPath (string path)
                {
                        string fullpath = InsecureGetFullPath (path);
+#if !NET_2_1
                        if (SecurityManager.SecurityEnabled) {
                                new FileIOPermission (FileIOPermissionAccess.PathDiscovery, fullpath).Demand ();
                        }
+#endif
                        return fullpath;
                }