Changeset 2170


Ignore:
Timestamp:
06/13/10 06:28:11 (4 years ago)
Author:
lowjoel
Message:

Forward-port from Eraser 6.0: Fix crash when a volume is connected but not mounted.

Location:
trunk/eraser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser

  • trunk/eraser/Eraser.DefaultPlugins/ErasureTargets/FolderErasureTarget.cs

    r2167 r2170  
    188188                bool isVolumeRoot = directory.Parent == null; 
    189189                foreach (VolumeInfo volume in VolumeInfo.Volumes) 
    190                     foreach (DirectoryInfo mountPoint in volume.MountPoints) 
    191                         if (directory.FullName == mountPoint.FullName) 
    192                             isVolumeRoot = true; 
     190                    if (volume.IsReady) 
     191                        foreach (DirectoryInfo mountPoint in volume.MountPoints) 
     192                            if (directory.FullName == mountPoint.FullName) 
     193                                isVolumeRoot = true; 
    193194 
    194195                //If the folder is a mount point, then don't delete it. If it isn't, 
  • trunk/eraser/Eraser.Util/VolumeInfo.cs

    r2149 r2170  
    9292        private List<string> GetLocalVolumeMountPoints() 
    9393        { 
     94            if (!IsReady) 
     95                throw new InvalidOperationException("The volume has not been mounted or is not " + 
     96                    "currently ready."); 
     97 
    9498            List<string> result = new List<string>(); 
    9599 
     
    406410            get 
    407411            { 
     412                if (!IsReady) 
     413                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     414                        "currently ready."); 
    408415                return (DriveType)NativeMethods.GetDriveType(VolumeId); 
    409416            } 
     
    417424            get 
    418425            { 
     426                if (!IsReady) 
     427                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     428                        "currently ready."); 
     429 
    419430                uint clusterSize, sectorSize, freeClusters, totalClusters; 
    420431                if (NativeMethods.GetDiskFreeSpace(VolumeId, out clusterSize, 
     
    435446            get 
    436447            { 
     448                if (!IsReady) 
     449                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     450                        "currently ready."); 
     451 
    437452                uint clusterSize, sectorSize, freeClusters, totalClusters; 
    438453                if (NativeMethods.GetDiskFreeSpace(VolumeId, out clusterSize, 
     
    453468            get 
    454469            { 
     470                if (!IsReady) 
     471                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     472                        "currently ready."); 
     473 
    455474                ulong freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes; 
    456475                if (NativeMethods.GetDiskFreeSpaceEx(VolumeId, out freeBytesAvailable, 
     
    481500            get 
    482501            { 
     502                if (!IsReady) 
     503                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     504                        "currently ready."); 
     505 
    483506                ulong result, dummy; 
    484507                if (NativeMethods.GetDiskFreeSpaceEx(VolumeId, out dummy, out dummy, out result)) 
     
    498521            get 
    499522            { 
     523                if (!IsReady) 
     524                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     525                        "currently ready."); 
     526 
    500527                ulong result, dummy; 
    501528                if (NativeMethods.GetDiskFreeSpaceEx(VolumeId, out dummy, out result, out dummy)) 
     
    515542            get 
    516543            { 
     544                if (!IsReady) 
     545                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     546                        "currently ready."); 
     547 
    517548                ulong result, dummy; 
    518549                if (NativeMethods.GetDiskFreeSpaceEx(VolumeId, out result, out dummy, out dummy)) 
     
    533564            get 
    534565            { 
     566                if (!IsReady) 
     567                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     568                        "currently ready."); 
     569 
    535570                List<VolumeInfo> result = new List<VolumeInfo>(); 
    536571                StringBuilder nextMountpoint = new StringBuilder(NativeMethods.LongPath * sizeof(char)); 
     
    569604            get 
    570605            { 
     606                if (!IsReady) 
     607                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     608                        "currently ready."); 
     609 
    571610                List<string> paths = VolumeType == DriveType.Network ? 
    572611                    GetNetworkMountPoints() : GetLocalVolumeMountPoints(); 
     
    581620        public bool IsMounted 
    582621        { 
    583             get { return MountPoints.Count != 0; } 
     622            get { return IsReady && MountPoints.Count != 0; } 
    584623        } 
    585624 
Note: See TracChangeset for help on using the changeset viewer.