X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.IO%2FMonoIO.cs;h=a1f4ed5deaab05904407d248624ba761249a13a9;hb=a4039fa632aedad177c3d90a38396469bfee3295;hp=0c46d07821839baafd4671948006d0c7948e39c6;hpb=07caf875a35f08ad23fc28382eff803c134d0807;p=mono.git diff --git a/mcs/class/corlib/System.IO/MonoIO.cs b/mcs/class/corlib/System.IO/MonoIO.cs index 0c46d078218..a1f4ed5deaa 100644 --- a/mcs/class/corlib/System.IO/MonoIO.cs +++ b/mcs/class/corlib/System.IO/MonoIO.cs @@ -47,7 +47,24 @@ 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."); + 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, @@ -63,7 +80,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 +92,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 +110,38 @@ 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_HANDLE_DISK_FULL: + message = String.Format ("Disk full. Path {0}", path); + 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); + + 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); 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); } } @@ -120,7 +154,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); @@ -143,6 +177,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); @@ -195,6 +236,20 @@ namespace System.IO return true; } + public static bool ExistsSymlink (string path, + out MonoIOError error) + { + FileAttributes attrs = GetFileAttributes (path, + out error); + if (attrs == InvalidFileAttributes) + return false; + + if ((attrs & FileAttributes.ReparsePoint) == 0) + return false; + + return true; + } + [MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static bool GetFileStat (string path, out MonoIOStat stat, @@ -207,7 +262,7 @@ namespace System.IO FileMode mode, FileAccess access, FileShare share, - bool async, + FileOptions options, out MonoIOError error); [MethodImplAttribute (MethodImplOptions.InternalCall)] @@ -298,7 +353,7 @@ namespace System.IO handle = Open (path, FileMode.Open, FileAccess.ReadWrite, - FileShare.ReadWrite, false, out error); + FileShare.ReadWrite, FileOptions.None, out error); if (handle == MonoIO.InvalidHandle) return false; @@ -378,11 +433,6 @@ namespace System.IO get; } - public extern static char [] InvalidPathChars { - [MethodImplAttribute (MethodImplOptions.InternalCall)] - get; - } - [MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static int GetTempPath(out string path); }