Changeset 1551
- Timestamp:
- 1/18/2010 5:23:07 AM (3 years ago)
- Location:
- branches/eraser6/CodeReview
- Files:
-
- 1 added
- 6 edited
-
Eraser.DefaultPlugins/FileSystems/Windows.cs (modified) (2 diffs)
-
Eraser.Manager/EntropySource.cs (modified) (2 diffs)
-
Eraser.Util/Eraser.Util.csproj (modified) (1 diff)
-
Eraser.Util/StreamInfo.cs (modified) (1 diff)
-
Eraser.Util/VolumeInfo.cs (modified) (7 diffs)
-
Eraser.Util/Win32ErrorCodes.cs (added)
-
Eraser/Program.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/CodeReview/Eraser.DefaultPlugins/FileSystems/Windows.cs
r1529 r1551 93 93 catch (IOException e) 94 94 { 95 switch ( System.Runtime.InteropServices.Marshal.GetLastWin32Error())95 switch ((Win32ErrorCodes)System.Runtime.InteropServices.Marshal.GetLastWin32Error()) 96 96 { 97 case 5: //ERROR_ACCESS_DENIED97 case Win32ErrorCodes.AccessDenied: 98 98 throw new UnauthorizedAccessException(S._("The file {0} could not " + 99 99 "be erased because the file's permissions prevent access to the file.", 100 100 info.FullName)); 101 101 102 case 32: //ERROR_SHARING_VIOLATION102 case Win32ErrorCodes.SharingViolation: 103 103 //If after FilenameEraseTries the file is still locked, some program is 104 104 //definitely using the file; throw an exception. … … 126 126 catch (IOException e) 127 127 { 128 switch ( System.Runtime.InteropServices.Marshal.GetLastWin32Error())128 switch ((Win32ErrorCodes)System.Runtime.InteropServices.Marshal.GetLastWin32Error()) 129 129 { 130 case 5: //ERROR_ACCESS_DENIED130 case Win32ErrorCodes.AccessDenied: 131 131 throw new UnauthorizedAccessException(S._("The file {0} could not " + 132 132 "be erased because the file's permissions prevent access to the file.", 133 133 info.FullName), e); 134 134 135 case 32: //ERROR_SHARING_VIOLATION135 case Win32ErrorCodes.SharingViolation: 136 136 //If after FilenameEraseTries the file is still locked, some program is 137 137 //definitely using the file; throw an exception. -
branches/eraser6/CodeReview/Eraser.Manager/EntropySource.cs
r1532 r1551 344 344 catch (System.ComponentModel.Win32Exception e) 345 345 { 346 if (e.NativeErrorCode != 5) //ERROR_ACCESS_DENIED346 if (e.NativeErrorCode != (int)Win32ErrorCodes.AccessDenied) 347 347 throw; 348 348 } … … 437 437 (uint)infoBuffer.Length, out dataWritten); 438 438 439 if (sysInfo == 0 /*ERROR_SUCCESS*/&& dataWritten > 0)439 if (sysInfo == (int)Win32ErrorCodes.Success && dataWritten > 0) 440 440 { 441 441 byte[] entropy = new byte[dataWritten]; -
branches/eraser6/CodeReview/Eraser.Util/Eraser.Util.csproj
r1548 r1551 85 85 <ItemGroup> 86 86 <Compile Include="NativeMethods\Sfc.cs" /> 87 <Compile Include="Win32ErrorCodes.cs" /> 87 88 </ItemGroup> 88 89 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
branches/eraser6/CodeReview/Eraser.Util/StreamInfo.cs
r1550 r1551 133 133 if (!handle.IsInvalid) 134 134 return true; 135 else if (Marshal.GetLastWin32Error() == 2 /*ERROR_FILE_NOT_FOUND*/)135 else if (Marshal.GetLastWin32Error() == (int)Win32ErrorCodes.FileNotFound) 136 136 return false; 137 137 -
branches/eraser6/CodeReview/Eraser.Util/VolumeInfo.cs
r1550 r1551 52 52 pathNamesBuffer, (uint)pathNamesBuffer.Capacity, out returnLength)) 53 53 { 54 if (Marshal.GetLastWin32Error() == 234 /*ERROR_MORE_DATA*/)54 if (Marshal.GetLastWin32Error() == (int)Win32ErrorCodes.MoreData) 55 55 pathNamesBuffer.EnsureCapacity((int)returnLength); 56 56 else … … 93 93 { 94 94 int lastError = Marshal.GetLastWin32Error(); 95 switch ( lastError)96 { 97 case 0: //ERROR_NO_ERROR98 case 21: //ERROR_NOT_READY99 case 87: //ERROR_INVALID_PARAMETER:when the volume given is not mounted.100 case 1005: //ERROR_UNRECOGNIZED_VOLUME95 switch ((Win32ErrorCodes)lastError) 96 { 97 case Win32ErrorCodes.Success: 98 case Win32ErrorCodes.NotReady: 99 case Win32ErrorCodes.InvalidParameter: //when the volume given is not mounted. 100 case Win32ErrorCodes.UnrecognizedVolume: 101 101 break; 102 102 … … 148 148 149 149 //Close the handle 150 if (Marshal.GetLastWin32Error() == 18 /*ERROR_NO_MORE_FILES*/)150 if (Marshal.GetLastWin32Error() == (int)Win32ErrorCodes.NoMoreFiles) 151 151 NativeMethods.FindVolumeClose(handle); 152 152 … … 177 177 else 178 178 { 179 switch ( Marshal.GetLastWin32Error())179 switch ((Win32ErrorCodes)Marshal.GetLastWin32Error()) 180 180 { 181 case 1: //ERROR_INVALID_FUNCTION182 case 2: //ERROR_FILE_NOT_FOUND183 case 3: //ERROR_PATH_NOT_FOUND184 case 4390: //ERROR_NOT_A_REPARSE_POINT181 case Win32ErrorCodes.InvalidFunction: 182 case Win32ErrorCodes.FileNotFound: 183 case Win32ErrorCodes.PathNotFound: 184 case Win32ErrorCodes.NotAReparsePoint: 185 185 break; 186 186 default: … … 194 194 195 195 throw Marshal.GetExceptionForHR(KernelApi.GetHRForWin32Error( 196 4390 /*ERROR_NOT_A_REPARSE_POINT*/));196 (int)Win32ErrorCodes.NotAReparsePoint)); 197 197 } 198 198 … … 272 272 return totalNumberOfFreeBytes != freeBytesAvailable; 273 273 } 274 else if (Marshal.GetLastWin32Error() == 21 /*ERROR_NOT_READY*/)274 else if (Marshal.GetLastWin32Error() == (int)Win32ErrorCodes.NotReady) 275 275 { 276 276 //For the lack of more appropriate responses. … … 362 362 363 363 //Close the handle 364 if (Marshal.GetLastWin32Error() == 18 /*ERROR_NO_MORE_FILES*/)364 if (Marshal.GetLastWin32Error() == (int)Win32ErrorCodes.NoMoreFiles) 365 365 NativeMethods.FindVolumeMountPointClose(handle); 366 366 -
branches/eraser6/CodeReview/Eraser/Program.cs
r1525 r1551 157 157 catch (UnauthorizedAccessException) 158 158 { 159 return 5; //ERROR_ACCESS_DENIED159 return (int)Win32ErrorCodes.AccessDenied; 160 160 } 161 161 catch (Win32Exception e)
Note: See TracChangeset
for help on using the changeset viewer.
