Added DriveNotFoundException.cs. MonoIO.cs: Added ERROR_INVALID_DRIVE handling. Pass...
authorKornél Pál <kornelpal@gmail.com>
Thu, 5 Jan 2006 14:32:22 +0000 (14:32 -0000)
committerKornél Pál <kornelpal@gmail.com>
Thu, 5 Jan 2006 14:32:22 +0000 (14:32 -0000)
svn path=/trunk/mcs/; revision=55102

mcs/class/corlib/ChangeLog
mcs/class/corlib/System.IO/ChangeLog
mcs/class/corlib/System.IO/DriveNotFoundException.cs [new file with mode: 0644]
mcs/class/corlib/System.IO/MonoIO.cs
mcs/class/corlib/System.IO/MonoIOError.cs
mcs/class/corlib/corlib.dll.sources

index 5ad674f442e0a222eb4802f0ce3b540890458c67..13214ce816515c5423dc2aa54e07ace12e42dd8f 100644 (file)
@@ -1,3 +1,7 @@
+2006-01-05  Kornél Pál  <kornelpal@hotmail.com>
+
+       * corlib.dll.sources: Added DriveNotFoundException.cs in System.IO.
+
 2005-12-23  Dick Porter  <dick@ximian.com>
 
        * corlib.dll.sources: Added System.Security.AccessControl.MutexRights
        * corlib.dll.sources: Added 
                System.Runtime.Serialization.Formatter.Binary.CodeGenerator.cs
 
-2004-02-10 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+2004-02-10 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
 
     * Mono.Security.Cryptography/PKCS1.cs:
 
        * corlib_test.dll.sources: Added unit tests PaddingMode and X509 
        using CryptoAPI.
 
-2003-12-14  Pedro Martú\8bez Juli\81E <yoros@wanadoo.es>
+2003-12-14  Pedro Martínez Juliá <yoros@wanadoo.es>
 
        * DateTime.cs: Be sure that the array access is not out of range
        when looking for ArgumentOutOfRangeException in the year value.
        * corlib.dll.sources: Added classes for Authenticode support.
        * corlib_test.dll.sources: Added unit test for SPC certificates.
 
-2003-09-26  Pedro Martú\8bez Jul\81E <yoros@wanadoo.es>
+2003-09-26  Pedro Martínez Juliá <yoros@wanadoo.es>
 
        * corlib_test.dll.sources: Remove tests that generate compile
        errors. The tests are still there but its name is rmoved here.
 
        * unix.args: Added System.Runtime.Remoting.Activation/AppDomainLevelActivator.cs
 
-2003-03-16  Pedro Martú\8bez Juli\81E <yoros@wanadoo.es>
+2003-03-16  Pedro Martínez Juliá <yoros@wanadoo.es>
 
        * unix.args: Added "System.FloatingPointFormatter.cs".
 
        * unix.args: Added
                System.Runtime.InteropServices/HandleRef.cs
 
-2003-03-04  Pedro Martú\8bez Juli\81E <yoros@wanadoo.es>
+2003-03-04  Pedro Martínez Juliá <yoros@wanadoo.es>
 
        * unix.args: Added "DoubleFormatter.cs" and "SingleFormatter.cs"
 
index 0c7f584fa89cf4a17151ef8049bac1e7f65f7238..7b886161b44cd17b03d09f43f82b2b2325ce618b 100644 (file)
@@ -1,9 +1,16 @@
+2006-01-05  Kornél Pál  <kornelpal@hotmail.com>
+
+       * DriveNotFoundException.cs: Added.
+       * MonoIO.cs: Added ERROR_INVALID_DRIVE handling. Pass HResult to
+         IOException constructors.
+       * MonoIOError.cs: Expose ERROR_INVALID_DRIVE.
+
 2006-01-02  Sebastien Pouliot  <sebastien@ximian.com>
 
        * UnexceptionalStreamReader.cs: Re-implemented the Read method to fix 
        the new line handling when reading from the Console (bug #77108).
 
-2005-12-24  Kornél Pál  <kornelpal@hotmail.com>
+2005-12-24  Kornél Pál  <kornelpal@hotmail.com>
 
        * FileStream.cs: Set buf_start to actual initial position when creating
          FileStreams from handles.
diff --git a/mcs/class/corlib/System.IO/DriveNotFoundException.cs b/mcs/class/corlib/System.IO/DriveNotFoundException.cs
new file mode 100644 (file)
index 0000000..fc8226b
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// System.IO.DriveNotFoundException.cs
+//
+// Author:
+//   Kornél Pál <http://www.kornelpal.hu/>
+//
+// Copyright (C) 2006 Kornél Pál
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+
+namespace System.IO
+{
+       [Serializable]
+       [ComVisible (true)]
+       public class DriveNotFoundException : IOException
+       {
+               private const int ErrorCode = unchecked((int)0x80070003);
+
+               // Constructors
+               public DriveNotFoundException ()
+                       : base ("Attempted to access a drive that is not available.")
+               {
+                       this.HResult = ErrorCode;
+               }
+
+               public DriveNotFoundException (string message)
+                       : base (message)
+               {
+                       this.HResult = ErrorCode;
+               }
+
+               public DriveNotFoundException (string message, Exception inner)
+                       : base (message, inner)
+               {
+                       this.HResult = ErrorCode;
+               }
+
+               protected DriveNotFoundException (SerializationInfo info, StreamingContext context)
+                       : base (info, context)
+               {
+               }
+       }
+}
+#endif
index 44fb37ed314b12ddda0308dd6c9901554b7e1935..cc62d6957e64d98fd88f38ebcb7f042b1bd8c386 100644 (file)
@@ -63,7 +63,7 @@ namespace System.IO
                                                                  path);
 
                        case MonoIOError.ERROR_TOO_MANY_OPEN_FILES:
-                               return new IOException ("Too many open files");
+                               return new IOException ("Too many open files", unchecked((int)0x80070000) | (int)error);
                                
                        case MonoIOError.ERROR_PATH_NOT_FOUND:
                                message = String.Format ("Could not find a part of the path \"{0}\"", path);
@@ -75,11 +75,17 @@ namespace System.IO
 
                        case MonoIOError.ERROR_INVALID_HANDLE:
                                message = String.Format ("Invalid handle to path \"{0}\"", path);
-                               return new IOException (message);
-                               
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
+                       case MonoIOError.ERROR_INVALID_DRIVE:
+                               message = String.Format ("Could not find the drive  '{0}'. The drive might not be ready or might not be mapped.", path);
+#if NET_2_0
+                               return new DriveNotFoundException (message);
+#else
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
+#endif
                        case MonoIOError.ERROR_FILE_EXISTS:
                                message = String.Format ("Could not create file \"{0}\". File already exists.", path);
-                               return new IOException (message);
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
 
                        case MonoIOError.ERROR_FILENAME_EXCED_RANGE:
                                message = String.Format ("Path is too long. Path: {0}", path); 
@@ -87,27 +93,27 @@ namespace System.IO
 
                        case MonoIOError.ERROR_INVALID_PARAMETER:
                                message = String.Format ("Invalid parameter");
-                               return new IOException (message);
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
 
                        case MonoIOError.ERROR_WRITE_FAULT:
                                message = String.Format ("Write fault on path {0}", path);
-                               return new IOException (message);
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
 
                        case MonoIOError.ERROR_SHARING_VIOLATION:
                                message = String.Format ("Sharing violation on path {0}", path);
-                               return new IOException (message);
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
                                
                        case MonoIOError.ERROR_LOCK_VIOLATION:
                                message = String.Format ("Lock violation on path {0}", path);
-                               return new IOException (message);
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
 
                        case MonoIOError.ERROR_DIR_NOT_EMPTY:
                                message = String.Format ("Directory {0} is not empty", path);
-                               return new IOException (message);
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
                                
                        default:
                                message = String.Format ("Win32 IO returned {0}. Path: {1}", error, path);
-                               return new IOException (message);
+                               return new IOException (message, unchecked((int)0x80070000) | (int)error);
                        }
                }
 
index 03e2476bf1fa14c9f0b00c0c1bcfe0d40bdaff2f..a3213d31b16836c05899f5f5ad3e608c61bc3a50 100644 (file)
@@ -50,8 +50,8 @@ namespace System.IO
                ERROR_INVALID_ACCESS = 12,\r
                ERROR_INVALID_DATA = 13,\r
                ERROR_OUTOFMEMORY = 14,\r
-               ERROR_INVALID_DRIVE = 15,\r
-               ERROR_CURRENT_DIRECTORY = 16,\r
+       */      ERROR_INVALID_DRIVE = 15,\r
+       /*      ERROR_CURRENT_DIRECTORY = 16,\r
                ERROR_NOT_SAME_DEVICE = 17,\r
        */      ERROR_NO_MORE_FILES = 18,\r
        /*      ERROR_WRITE_PROTECT = 19,\r
index d9af9e1a86f6e6ac6814c38b48bed7902efbc723..93f3a27101bba00bb1650083e90b43cf7182559c 100644 (file)
@@ -332,6 +332,7 @@ System.IO/CheckPermission.cs
 System.IO/Directory.cs
 System.IO/DirectoryInfo.cs
 System.IO/DirectoryNotFoundException.cs
+System.IO/DriveNotFoundException.cs
 System.IO/EndOfStreamException.cs
 System.IO/File.cs
 System.IO/FileAccess.cs