Changeset 1051


Ignore:
Timestamp:
5/10/2009 9:46:13 AM (5 years ago)
Author:
lowjoel
Message:

If the user specifies that a folder should be deleted if empty, and the folder turns out to be a volume mount point, don't try to delete the folder.

  1. The folder won't be deleted if it is the root, i.e. try erasing D:\ and deleting it if empty.
  2. The user may not want to delete a mount point, i.e. a volume mounted at C:\Data
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Manager/DirectExecutor.cs

    r1040 r1051  
    878878                { 
    879879                    DirectoryInfo info = new DirectoryInfo(fldr.Path); 
    880                     if (info.GetFiles("*", SearchOption.AllDirectories).Length == 0) 
     880 
     881                    //See if this is the root of a volume. 
     882                    bool isVolumeRoot = info.Parent == null; 
     883                    foreach (VolumeInfo volume in VolumeInfo.Volumes) 
     884                        foreach (string mountPoint in volume.MountPoints) 
     885                            if (info.FullName == mountPoint) 
     886                                isVolumeRoot = true; 
     887 
     888                    //If the folder is a mount point, then don't delete it. If it isn't, 
     889                    //search for files under the folder to see if it is empty. 
     890                    if (!isVolumeRoot && info.GetFiles("*", SearchOption.AllDirectories).Length == 0) 
    881891                    { 
    882892                        FileSystem fsManager = FileSystem.Get(VolumeInfo.FromMountpoint(fldr.Path)); 
Note: See TracChangeset for help on using the changeset viewer.