Changeset 1872
- Timestamp:
- 3/1/2010 9:36:02 AM (3 years ago)
- Location:
- trunk/eraser6
- Files:
-
- 2 added
- 4 edited
-
Eraser.Manager/DirectExecutor.cs (modified) (3 diffs)
-
Eraser.Manager/Task.cs (modified) (1 diff)
-
Eraser.Util/Eraser.Util.csproj (modified) (1 diff)
-
Eraser.Util/ExtensionClasses (added)
-
Eraser.Util/ExtensionClasses/SharingViolationException.cs (added)
-
Eraser.Util/Win32ErrorCodes.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6/Eraser.Manager/DirectExecutor.cs
r1864 r1872 309 309 throw; 310 310 } 311 catch (SharingViolationException) 312 { 313 } 311 314 catch (ThreadAbortException) 312 315 { … … 331 334 //is executed. This is here mainly to ensure that no BlackBox 332 335 //report is created for this exception. 336 } 337 catch (SharingViolationException) 338 { 333 339 } 334 340 catch (Exception e) … … 674 680 "permissions prevent access to the file.", info.FullName), LogLevel.Error); 675 681 } 676 catch ( IOException)677 { 678 if ( System.Runtime.InteropServices.Marshal.GetLastWin32Error() ==679 Win32ErrorCode.SharingViolation)680 { 681 if (!ManagerLibrary.Settings.ForceUnlockLockedFiles)682 throw;683 684 List<System.Diagnostics.Process> processes =685 new List<System.Diagnostics.Process>();686 foreach (OpenHandle handle in OpenHandle.Items) 687 if (handle.Path == paths[i])688 processes.Add(System.Diagnostics.Process.GetProcessById(handle.ProcessId));689 690 string lockedBy = null;691 if (processes.Count > 0)682 catch (SharingViolationException) 683 { 684 if (!ManagerLibrary.Settings.ForceUnlockLockedFiles) 685 throw; 686 687 List<System.Diagnostics.Process> processes = 688 new List<System.Diagnostics.Process>(); 689 foreach (OpenHandle handle in OpenHandle.Items) 690 if (handle.Path == paths[i]) 691 processes.Add(System.Diagnostics.Process.GetProcessById(handle.ProcessId)); 692 693 string lockedBy = null; 694 if (processes.Count > 0) 695 { 696 StringBuilder processStr = new StringBuilder(); 697 foreach (System.Diagnostics.Process process in processes) 692 698 { 693 StringBuilder processStr = new StringBuilder(); 694 foreach (System.Diagnostics.Process process in processes) 699 try 695 700 { 696 try 697 { 698 processStr.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, 699 "{0}, ", process.MainModule.FileName); 700 } 701 catch (System.ComponentModel.Win32Exception) 702 { 703 } 701 processStr.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, 702 "{0}, ", process.MainModule.FileName); 704 703 } 705 706 lockedBy = S._("(locked by {0})", processStr.ToString().Remove(processStr.Length - 2)); 704 catch (System.ComponentModel.Win32Exception) 705 { 706 } 707 707 } 708 708 709 Logger.Log(S._("Could not force closure of file \"{0}\" {1}", paths[i],710 lockedBy == null ? string.Empty : lockedBy).Trim(), LogLevel.Error);711 } 712 else713 throw;709 lockedBy = S._("(locked by {0})", processStr.ToString().Remove(processStr.Length - 2)); 710 } 711 712 Logger.Log(S._("Could not force closure of file \"{0}\" {1}", paths[i], 713 lockedBy == null ? string.Empty : lockedBy).Trim(), LogLevel.Error); 714 714 } 715 715 finally -
trunk/eraser6/Eraser.Manager/Task.cs
r1853 r1872 461 461 { 462 462 } 463 catch (IOException) 464 { 465 if (System.Runtime.InteropServices.Marshal.GetLastWin32Error() == 466 Win32ErrorCode.SharingViolation) 467 { 468 //The system cannot open the file, try to force the file handle to close. 469 if (!ManagerLibrary.Settings.ForceUnlockLockedFiles) 470 throw; 471 472 foreach (OpenHandle handle in OpenHandle.Items) 473 if (handle.Path == file && handle.Close()) 474 { 475 GetPathADSes(list, out totalSize, file); 476 return; 477 } 478 } 479 else 463 catch (SharingViolationException) 464 { 465 //The system cannot open the file, try to force the file handle to close. 466 if (!ManagerLibrary.Settings.ForceUnlockLockedFiles) 480 467 throw; 468 469 foreach (OpenHandle handle in OpenHandle.Items) 470 if (handle.Path == file && handle.Close()) 471 { 472 GetPathADSes(list, out totalSize, file); 473 return; 474 } 481 475 } 482 476 catch (UnauthorizedAccessException e) -
trunk/eraser6/Eraser.Util/Eraser.Util.csproj
r1832 r1872 113 113 <Compile Include="NativeMethods\Sfc.cs" /> 114 114 <Compile Include="ProgressManager.cs" /> 115 <Compile Include="ExtensionClasses\SharingViolationException.cs" /> 115 116 <Compile Include="Shell.cs" /> 116 117 <Compile Include="Win32ErrorCodes.cs" /> -
trunk/eraser6/Eraser.Util/Win32ErrorCodes.cs
r1802 r1872 32 32 { 33 33 /// <summary> 34 /// Gets the error message associated with the provided system error code. 35 /// </summary> 36 /// <param name="code">The system error code which should have the message queried.</param> 37 /// <returns>The string describing the error with the given error code.</returns> 38 public static string GetSystemErrorMessage(int code) 39 { 40 return new System.ComponentModel.Win32Exception(code).Message; 41 } 42 43 /// <summary> 34 44 /// Converts a Win32 Error code to a HRESULT. 35 45 /// </summary> … … 53 63 { 54 64 case NoError: return null; 55 case SharingViolation: return new IOException();65 case SharingViolation: return new SharingViolationException(); 56 66 } 57 67
Note: See TracChangeset
for help on using the changeset viewer.
