Changeset 1783


Ignore:
Timestamp:
2/9/2010 8:36:16 AM (4 years ago)
Author:
lowjoel
Message:

Forward port from Eraser 6.0: Fixed DirectoryNotFoundException? -- the Erase If Empty option for directories were not respected -- directories were always erased.
Also reverted erroneous change in r1700 which removed the mountpoint checking code.

Location:
trunk/eraser6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6

  • trunk/eraser6/Eraser.Manager/DirectExecutor.cs

    r1755 r1783  
    722722                         fsManager.DeleteFolder(info); 
    723723                }; 
    724                 eraseEmptySubFolders(new DirectoryInfo(fldr.Path)); 
     724 
     725                DirectoryInfo directory = new DirectoryInfo(fldr.Path); 
     726                foreach (DirectoryInfo subDir in directory.GetDirectories()) 
     727                    eraseEmptySubFolders(subDir); 
    725728 
    726729                if (fldr.DeleteIfEmpty) 
    727730                { 
    728                     DirectoryInfo info = new DirectoryInfo(fldr.Path); 
    729                     task.OnProgressChanged(target, 
    730                         new ProgressChangedEventArgs(step, 
    731                             new TaskProgressChangedEventArgs(info.FullName, 0, 0))); 
    732                     fsManager.DeleteFolder(info); 
     731                    //See if this is the root of a volume. 
     732                    bool isVolumeRoot = directory.Parent == null; 
     733                    foreach (VolumeInfo volume in VolumeInfo.Volumes) 
     734                        foreach (string mountPoint in volume.MountPoints) 
     735                            if (directory.FullName == mountPoint) 
     736                                isVolumeRoot = true; 
     737 
     738                    //If the folder is a mount point, then don't delete it. If it isn't, 
     739                    //search for files under the folder to see if it is empty. 
     740                    if (!isVolumeRoot && directory.Exists && 
     741                        directory.GetFiles("*", SearchOption.AllDirectories).Length == 0) 
     742                    { 
     743                        fsManager.DeleteFolder(directory); 
     744                    } 
    733745                } 
    734746            } 
Note: See TracChangeset for help on using the changeset viewer.