|
1 | | -/* Copyright (C) 2018 Tal Aloni <[email protected]>. All rights reserved. |
| 1 | +/* Copyright (C) 2018-2024 Tal Aloni <[email protected]>. All rights reserved. |
2 | 2 | * |
3 | 3 | * You can redistribute this program and/or modify it under the terms of |
4 | 4 | * the GNU Lesser Public License as published by the Free Software Foundation, |
@@ -37,37 +37,37 @@ public static int GetHResultFromWin32Error(Win32Error error) |
37 | 37 | } |
38 | 38 | } |
39 | 39 |
|
40 | | - /// <param name="errorCode">The Win32 error code associated with this exception</param> |
41 | | - internal static void ThrowIOError(int errorCode, string defaultMessage) |
| 40 | + /// <param name="win32ErrorCode">The Win32 error code associated with the exception to throw</param> |
| 41 | + public static void ThrowIOError(int win32ErrorCode, string defaultMessage) |
42 | 42 | { |
43 | | - if (errorCode == (int)Win32Error.ERROR_ACCESS_DENIED) |
| 43 | + if (win32ErrorCode == (int)Win32Error.ERROR_ACCESS_DENIED) |
44 | 44 | { |
45 | 45 | // UnauthorizedAccessException will be thrown if stream was opened only for writing or if a user is not an administrator |
46 | 46 | throw new UnauthorizedAccessException(defaultMessage); |
47 | 47 | } |
48 | | - else if (errorCode == (int)Win32Error.ERROR_SHARING_VIOLATION) |
| 48 | + else if (win32ErrorCode == (int)Win32Error.ERROR_SHARING_VIOLATION) |
49 | 49 | { |
50 | 50 | throw new SharingViolationException(defaultMessage); |
51 | 51 | } |
52 | | - else if (errorCode == (int)Win32Error.ERROR_SECTOR_NOT_FOUND) |
| 52 | + else if (win32ErrorCode == (int)Win32Error.ERROR_SECTOR_NOT_FOUND) |
53 | 53 | { |
54 | 54 | string message = defaultMessage + " The sector does not exist."; |
55 | | - int hresult = GetHResultFromWin32Error((Win32Error)errorCode); |
| 55 | + int hresult = GetHResultFromWin32Error((Win32Error)win32ErrorCode); |
56 | 56 | throw new IOException(message, hresult); |
57 | 57 | } |
58 | | - else if (errorCode == (int)Win32Error.ERROR_CRC) |
| 58 | + else if (win32ErrorCode == (int)Win32Error.ERROR_CRC) |
59 | 59 | { |
60 | 60 | string message = defaultMessage + " Data Error (Cyclic Redundancy Check)."; |
61 | 61 | throw new CyclicRedundancyCheckException(message); |
62 | 62 | } |
63 | | - else if (errorCode == (int)Win32Error.ERROR_NO_SYSTEM_RESOURCES) |
| 63 | + else if (win32ErrorCode == (int)Win32Error.ERROR_NO_SYSTEM_RESOURCES) |
64 | 64 | { |
65 | 65 | throw new OutOfMemoryException(); |
66 | 66 | } |
67 | 67 | else |
68 | 68 | { |
69 | | - string message = defaultMessage + String.Format(" Win32 Error: {0}", errorCode); |
70 | | - int hresult = GetHResultFromWin32Error((Win32Error)errorCode); |
| 69 | + string message = defaultMessage + String.Format(" Win32 Error: {0}", win32ErrorCode); |
| 70 | + int hresult = GetHResultFromWin32Error((Win32Error)win32ErrorCode); |
71 | 71 | throw new IOException(message, hresult); |
72 | 72 | } |
73 | 73 | } |
|
0 commit comments