X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.IO%2FMonoIO.cs;h=0dbd3d67570414b4ef9735761f3b46732affacfe;hb=3c39ac4586b4470703fb4af0208b5baf1de70e43;hp=21c21b236c99a17c83d9eda1879e7ad9050f716f;hpb=53e266903ec6b2d822cf5b0c566f6374df5307a4;p=mono.git diff --git a/mcs/class/corlib/System.IO/MonoIO.cs b/mcs/class/corlib/System.IO/MonoIO.cs index 21c21b236c9..0dbd3d67570 100644 --- a/mcs/class/corlib/System.IO/MonoIO.cs +++ b/mcs/class/corlib/System.IO/MonoIO.cs @@ -34,6 +34,9 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; +#if NET_2_1 +using System.IO.IsolatedStorage; +#endif namespace System.IO { @@ -47,7 +50,27 @@ namespace System.IO // error methods public static Exception GetException (MonoIOError error) { - return GetException (String.Empty, error); + /* This overload is currently only called from + * File.MoveFile(), Directory.Move() and + * Directory.GetCurrentDirectory() - + * everywhere else supplies a path to format + * with the error text. + */ + switch(error) { + case MonoIOError.ERROR_ACCESS_DENIED: + return new UnauthorizedAccessException ("Access to the path is denied."); + case MonoIOError.ERROR_FILE_EXISTS: + string message = "Cannot create a file that already exist."; + return new IOException (message, unchecked ((int) 0x80070000) | (int) error); + default: + /* Add more mappings here if other + * errors trigger the named but empty + * path bug (see bug 82141.) For + * everything else, fall through to + * the other overload + */ + return GetException (String.Empty, error); + } } public static Exception GetException (string path, @@ -59,15 +82,22 @@ namespace System.IO // FIXME: add more exception mappings here case MonoIOError.ERROR_FILE_NOT_FOUND: message = String.Format ("Could not find file \"{0}\"", path); - return new FileNotFoundException (message, - path); +#if NET_2_1 + return new IsolatedStorageException (message); +#else + return new FileNotFoundException (message, path); +#endif case MonoIOError.ERROR_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); +#if NET_2_1 + return new IsolatedStorageException (message); +#else return new DirectoryNotFoundException (message); +#endif case MonoIOError.ERROR_ACCESS_DENIED: message = String.Format ("Access to the path \"{0}\" is denied.", path); @@ -78,7 +108,7 @@ namespace System.IO 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 +#if !NET_2_1 return new DriveNotFoundException (message); #else return new IOException (message, unchecked((int)0x80070000) | (int)error); @@ -117,6 +147,14 @@ namespace System.IO case MonoIOError.ERROR_ENCRYPTION_FAILED: return new IOException ("Encryption failed", unchecked((int)0x80070000) | (int)error); + + case MonoIOError.ERROR_CANNOT_MAKE: + message = String.Format ("Path {0} is a directory", path); + return new IOException (message, unchecked((int)0x80070000) | (int)error); + + case MonoIOError.ERROR_NOT_SAME_DEVICE: + message = "Source and destination are not on the same device"; + return new IOException (message, unchecked((int)0x80070000) | (int)error); default: message = String.Format ("Win32 IO returned {0}. Path: {1}", error, path); @@ -133,7 +171,7 @@ namespace System.IO public extern static bool RemoveDirectory (string path, out MonoIOError error); [MethodImplAttribute (MethodImplOptions.InternalCall)] - public extern static string [] GetFileSystemEntries (string path, string pattern, int attrs, int mask, out MonoIOError error); + public extern static string [] GetFileSystemEntries (string path, string path_with_pattern, int attrs, int mask, out MonoIOError error); [MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static string GetCurrentDirectory (out MonoIOError error); @@ -156,6 +194,13 @@ namespace System.IO public extern static bool DeleteFile (string path, out MonoIOError error); + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static bool ReplaceFile (string sourceFileName, + string destinationFileName, + string destinationBackupFileName, + bool ignoreMetadataErrors, + out MonoIOError error); + [MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static FileAttributes GetFileAttributes (string path, out MonoIOError error); @@ -383,6 +428,10 @@ namespace System.IO [MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static bool CreatePipe (out IntPtr read_handle, out IntPtr write_handle); + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static bool DuplicateHandle (IntPtr source_process_handle, IntPtr source_handle, + IntPtr target_process_handle, out IntPtr target_handle, int access, int inherit, int options); + // path characters public extern static char VolumeSeparatorChar {