Changeset 1131
- Timestamp:
- 6/16/2009 3:55:37 AM (4 years ago)
- File:
-
- 1 edited
-
trunk/eraser6/Eraser.Manager/DirectExecutor.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6/Eraser.Manager/DirectExecutor.cs
r1102 r1131 800 800 try 801 801 { 802 //Otherwise, create the stream, lengthen the file, then tell the erasure 803 //method to erase the cluster tips. 804 using (FileStream stream = streamInfo.Open(FileMode.Open, FileAccess.Write, 805 FileShare.None, FileOptions.WriteThrough)) 806 { 807 try 808 { 809 stream.SetLength(fileArea); 810 stream.Seek(fileLength, SeekOrigin.Begin); 811 812 //Erase the file 813 method.Erase(stream, long.MaxValue, PrngManager.GetInstance( 814 ManagerLibrary.Settings.ActivePrng), null); 802 try 803 { 804 //Otherwise, create the stream, lengthen the file, then tell the erasure 805 //method to erase the cluster tips. 806 using (FileStream stream = streamInfo.Open(FileMode.Open, FileAccess.Write, 807 FileShare.None, FileOptions.WriteThrough)) 808 { 809 try 810 { 811 stream.SetLength(fileArea); 812 stream.Seek(fileLength, SeekOrigin.Begin); 813 814 //Erase the file 815 method.Erase(stream, long.MaxValue, PrngManager.GetInstance( 816 ManagerLibrary.Settings.ActivePrng), null); 817 } 818 finally 819 { 820 //Make sure the file length is restored! 821 stream.SetLength(fileLength); 822 } 815 823 } 816 finally 817 { 818 //Make sure the file length is restored! 819 stream.SetLength(fileLength); 820 } 821 } 822 } 823 finally 824 { 825 //Reset the file times 826 streamInfo.LastAccessTime = lastAccess; 827 streamInfo.LastWriteTime = lastWrite; 828 streamInfo.CreationTime = created; 824 } 825 finally 826 { 827 //Reset the file times 828 streamInfo.LastAccessTime = lastAccess; 829 streamInfo.LastWriteTime = lastWrite; 830 streamInfo.CreationTime = created; 831 } 832 } 833 catch (UnauthorizedAccessException) 834 { 829 835 } 830 836 } … … 973 979 task.OnProgressChanged(progress.Event); 974 980 981 //Remove all subfolders which are empty. 975 982 FolderTarget fldr = (FolderTarget)target; 983 FileSystem fsManager = FileSystem.Get(VolumeInfo.FromMountpoint(fldr.Path)); 984 SubFoldersHandler eraseEmptySubFolders = null; 985 eraseEmptySubFolders = delegate(DirectoryInfo info) 986 { 987 foreach (DirectoryInfo subDir in info.GetDirectories()) 988 eraseEmptySubFolders(subDir); 989 FileSystemInfo[] files = info.GetFileSystemInfos(); 990 if (files.Length == 0) 991 fsManager.DeleteFolder(info); 992 }; 993 eraseEmptySubFolders(new DirectoryInfo(fldr.Path)); 994 976 995 if (fldr.DeleteIfEmpty) 977 996 { … … 988 1007 //search for files under the folder to see if it is empty. 989 1008 if (!isVolumeRoot && info.Exists && info.GetFiles("*", SearchOption.AllDirectories).Length == 0) 990 {991 FileSystem fsManager = FileSystem.Get(VolumeInfo.FromMountpoint(fldr.Path));992 1009 fsManager.DeleteFolder(info); 993 }994 1010 } 995 1011 }
Note: See TracChangeset
for help on using the changeset viewer.
