Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Win32Marshal.cs
Go to the documentation of this file.
1namespace System.IO;
2
3internal static class Win32Marshal
4{
5 internal static Exception GetExceptionForWin32Error(int errorCode, string path = "")
6 {
7 switch (errorCode)
8 {
9 case 2:
10 return new FileNotFoundException(string.IsNullOrEmpty(path) ? System.SR.IO_FileNotFound : System.SR.Format(System.SR.IO_FileNotFound_FileName, path), path);
11 case 3:
13 case 5:
15 case 183:
16 if (!string.IsNullOrEmpty(path))
17 {
19 }
20 break;
21 case 206:
22 return new PathTooLongException(string.IsNullOrEmpty(path) ? System.SR.IO_PathTooLong : System.SR.Format(System.SR.IO_PathTooLong_Path, path));
23 case 32:
24 return new IOException(string.IsNullOrEmpty(path) ? System.SR.IO_SharingViolation_NoFileName : System.SR.Format(System.SR.IO_SharingViolation_File, path), MakeHRFromErrorCode(errorCode));
25 case 80:
26 if (!string.IsNullOrEmpty(path))
27 {
29 }
30 break;
31 case 995:
32 return new OperationCanceledException();
33 }
34 return new IOException(string.IsNullOrEmpty(path) ? GetMessage(errorCode) : (GetMessage(errorCode) + " : '" + path + "'"), MakeHRFromErrorCode(errorCode));
35 }
36
37 internal static int MakeHRFromErrorCode(int errorCode)
38 {
39 if ((0xFFFF0000u & errorCode) != 0L)
40 {
41 return errorCode;
42 }
43 return -2147024896 | errorCode;
44 }
45
46 internal static string GetMessage(int errorCode)
47 {
48 return global::Interop.Kernel32.GetMessage(errorCode);
49 }
50}
static int MakeHRFromErrorCode(int errorCode)
static string GetMessage(int errorCode)
static Exception GetExceptionForWin32Error(int errorCode, string path="")
static string IO_FileExists_Name
Definition SR.cs:36
static string IO_PathTooLong
Definition SR.cs:46
static string IO_AlreadyExists_Name
Definition SR.cs:34
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string IO_SharingViolation_File
Definition SR.cs:52
static string UnauthorizedAccess_IODenied_Path
Definition SR.cs:50
static string IO_SharingViolation_NoFileName
Definition SR.cs:54
static string IO_PathNotFound_NoPathName
Definition SR.cs:42
static string IO_FileNotFound
Definition SR.cs:38
static string IO_FileNotFound_FileName
Definition SR.cs:40
static string IO_PathTooLong_Path
Definition SR.cs:94
static string IO_PathNotFound_Path
Definition SR.cs:44
static string UnauthorizedAccess_IODenied_NoPathName
Definition SR.cs:48
Definition SR.cs:7