2002-08-21 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Wed, 21 Aug 2002 23:38:23 +0000 (23:38 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 21 Aug 2002 23:38:23 +0000 (23:38 -0000)
* Environment.cs: Implemented OSVersion property.

2002-08-21  Miguel de Icaza  <miguel@ximian.com>

* Path.cs (GetDirectoryName): Fix for filenames with size = 1

* File.cs: Removed all references that threw exceptions when the
paths contains a colon, as this is a valid part of an identifier
on Unix.

Everywhere: The String.Empty return from GetDirectoryName means
that there is no directory information about the path.

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

mcs/class/corlib/System.IO/ChangeLog
mcs/class/corlib/System.IO/File.cs
mcs/class/corlib/System.IO/Path.cs
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Environment.cs

index ed571fae9e53b096c5e81b487dc6a6c6bb3cb3de..7f2836d5b7f6ca3748e5af46ffd6c2b2407835c6 100644 (file)
@@ -1,3 +1,14 @@
+2002-08-21  Miguel de Icaza  <miguel@ximian.com>
+
+       * Path.cs (GetDirectoryName): Fix for filenames with size = 1
+
+       * File.cs: Removed all references that threw exceptions when the
+       paths contains a colon, as this is a valid part of an identifier
+       on Unix.
+
+       Everywhere: The String.Empty return from GetDirectoryName means
+       that there is no directory information about the path.
+
 2002-08-20  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * FileNotFoundException.cs: use Message and InnerException from base
index 6032a1b8beb8a4d257a8cf77486921300e2ca6ed..b4d20e6802ab8445169669a5bee9d118ef2d7915 100644 (file)
@@ -45,18 +45,13 @@ namespace System.IO
                                throw new ArgumentException ("src");\r
                        if (dest.Trim () == "" || dest.IndexOfAny (Path.InvalidPathChars) != -1)\r
                                throw new ArgumentException ("dest");\r
-                       if (src.IndexOf(':') > 1)\r
-                               throw new NotSupportedException("src");\r
-                       if (dest.IndexOf(':') > 1)\r
-                               throw new NotSupportedException("dest");\r
-                       if (!Exists (src)) {\r
+                       if (!Exists (src))
                                throw new FileNotFoundException (src + " does not exist");\r
-                       }\r
-                       else {\r
-                               if ((GetAttributes(src) & FileAttributes.Directory) == FileAttributes.Directory){\r
-                                       throw new ArgumentException(src + " is a directory");   \r
-                               }\r
-                       }\r
+
+                       if ((GetAttributes(src) & FileAttributes.Directory) == FileAttributes.Directory){
+                               throw new ArgumentException(src + " is a directory");
+                       }
+                       
                        if (Exists (dest)) {\r
                                if ((GetAttributes(dest) & FileAttributes.Directory) == FileAttributes.Directory){\r
                                        throw new ArgumentException(dest + " is a directory");  \r
@@ -66,8 +61,8 @@ namespace System.IO
                        }\r
 \r
                        string DirName = Path.GetDirectoryName(dest);\r
-                       if (!Directory.Exists (DirName))\r
-                               throw new DirectoryNotFoundException("Destination directory not found: " + DirName);\r
+                       if (DirName != String.Empty && !Directory.Exists (DirName))
+                               throw new DirectoryNotFoundException("Destination directory not found: " + DirName);
 \r
                        if (!MonoIO.CopyFile (src, dest, overwrite))\r
                                throw MonoIO.GetException ();\r
@@ -84,8 +79,6 @@ namespace System.IO
                                throw new ArgumentNullException("path");\r
                        if (String.Empty == path.Trim() || path.IndexOfAny(Path.InvalidPathChars) >= 0)\r
                                throw new ArgumentException("path");\r
-                       if (path.IndexOf(':') > 1)\r
-                               throw new NotSupportedException();\r
 \r
                        string DirName = Path.GetDirectoryName(path);\r
                        if (DirName != String.Empty && !Directory.Exists (DirName))\r
@@ -115,13 +108,11 @@ namespace System.IO
                                throw new ArgumentNullException("path");\r
                        if (String.Empty == path.Trim() || path.IndexOfAny(Path.InvalidPathChars) >= 0)\r
                                throw new ArgumentException("path");\r
-                       if (path.IndexOf(':') > 1)\r
-                               throw new NotSupportedException();\r
                        if (Directory.Exists (path))\r
                                throw new UnauthorizedAccessException("path is a directory");\r
 \r
                        string DirName = Path.GetDirectoryName(path);\r
-                       if (DirName.Length > 0 && !Directory.Exists (DirName))\r
+                       if (DirName != String.Empty && !Directory.Exists (DirName))\r
                                throw new DirectoryNotFoundException("Destination directory not found: " + DirName);\r
 \r
                        if (!MonoIO.DeleteFile (path)){\r
@@ -137,8 +128,7 @@ namespace System.IO
                        // is any problem with the path or permissions.  Minimizes what information can be\r
                        // discovered by using this method.\r
                        if (null == path || String.Empty == path.Trim() \r
-                               || path.IndexOfAny(Path.InvalidPathChars) >= 0\r
-                               || path.IndexOf(':') > 1)\r
+                           || path.IndexOfAny(Path.InvalidPathChars) >= 0)
                                return false;\r
 \r
                        return MonoIO.ExistsFile (path);\r
@@ -150,12 +140,6 @@ namespace System.IO
                                throw new ArgumentNullException("path");\r
                        if (String.Empty == path.Trim() || path.IndexOfAny(Path.InvalidPathChars) >= 0)\r
                                throw new ArgumentException("path");\r
-                       if (path.IndexOf(':') > 1)\r
-                               throw new NotSupportedException();\r
-\r
-                       string DirName = Path.GetDirectoryName(path);\r
-                       if (!Directory.Exists(DirName))\r
-                               throw new DirectoryNotFoundException("Directory '" + DirName + "' not found in '" + Environment.CurrentDirectory + "'.");\r
 \r
                        return MonoIO.GetFileAttributes (path);\r
                }\r
@@ -194,10 +178,6 @@ namespace System.IO
                                throw new ArgumentException ("src");\r
                        if (dest.Trim () == "" || dest.IndexOfAny (Path.InvalidPathChars) != -1)\r
                                throw new ArgumentException ("dest");\r
-                       if (src.IndexOf(':') > 1)\r
-                               throw new NotSupportedException("src");\r
-                       if (dest.IndexOf(':') > 1)\r
-                               throw new NotSupportedException("dest");\r
                        if (!Exists (src))\r
                                throw new FileNotFoundException (src + " does not exist");\r
                        if (Exists (dest) && ((GetAttributes(dest) & FileAttributes.Directory) == FileAttributes.Directory))\r
@@ -205,10 +185,10 @@ namespace System.IO
 \r
                        string DirName;\r
                        DirName = Path.GetDirectoryName(src);\r
-                       if (!Directory.Exists (DirName))\r
+                       if (DirName != String.Empty && !Directory.Exists (DirName))\r
                                throw new DirectoryNotFoundException("Source directory not found: " + DirName);\r
                        DirName = Path.GetDirectoryName(dest);\r
-                       if (!Directory.Exists (DirName))\r
+                       if (DirName != String.Empty && !Directory.Exists (DirName))\r
                                throw new DirectoryNotFoundException("Destination directory not found: " + DirName);\r
 \r
                        if (!MonoIO.MoveFile (src, dest))\r
index e066ffe89342428106911fa5d069481c90240bf7..8e9b5945320765cb54cf069c32f29b8eff47a303 100644 (file)
@@ -104,7 +104,7 @@ namespace System.IO
                                CheckArgument.WhitespaceOnly (path);
                                CheckArgument.PathChars (path);
 
-                               if (path.Length > 2)
+                               if (path.Length > 0)
                                {
                                        int nLast = path.LastIndexOfAny (PathSeparatorChars);
 
@@ -112,7 +112,7 @@ namespace System.IO
                                                return path.Substring (0, nLast);
                                        else
                                                return String.Empty;
-                               }
+                               } 
                        }
                        return path;
                }
index 0b1d6ac0a3b8c31b885871aa0616071bd7b8018b..0725bbe48e609e0aa1a9ee4651282c2ff526c220 100644 (file)
@@ -1,3 +1,7 @@
+2002-08-21  Miguel de Icaza  <miguel@ximian.com>
+
+       * Environment.cs: Implemented OSVersion property.
+
 2002-08-21  Dietmar Maurer  <dietmar@ximian.com>
 
        * Exception.cs: set stack_trace to null
index ccb608bff74357d7ea3e1c61067f3f3c2f9f2fcb..94483de627fa87c2c9f3c484efa780fa66b7b724 100644 (file)
@@ -93,7 +93,7 @@ namespace System
                /// </summary>\r
                [MonoTODO]\r
                public static int ExitCode\r
-               {       // TODO: find a way to implement this property\r
+               {       \r
                        get\r
                        {\r
                                throw new NotImplementedException ();\r
@@ -120,14 +120,26 @@ namespace System
                        get;\r
                }\r
 \r
+\r
+               //\r
+               // Support methods and fields for OSVersion property\r
+               //\r
+               static OperatingSystem os;\r
+\r
+               static extern PlatformID Platform {\r
+                       [MethodImplAttribute (MethodImplOptions.InternalCall)]\r
+                       get;\r
+               }\r
+\r
                /// <summary>\r
                /// Gets the current OS version information\r
                /// </summary>\r
-               [MonoTODO]\r
                public static OperatingSystem OSVersion {\r
-                       get\r
-                       {\r
-                               return null;\r
+                       get {\r
+                               if (os == null)\r
+                                       os = new OperatingSystem (Platform, new Version (5,1,2600,0));\r
+\r
+                               return os;\r
                        }\r
                }\r
 \r