Changeset 2168 for branches/eraser6/6.0


Ignore:
Timestamp:
6/13/2010 6:21:46 AM (4 years ago)
Author:
lowjoel
Message:

Fix crash when a volume is connected but not mounted.

Location:
branches/eraser6/6.0
Files:
2 edited

Legend:

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

    r2166 r2168  
    893893                    bool isVolumeRoot = directory.Parent == null; 
    894894                    foreach (VolumeInfo volume in VolumeInfo.Volumes) 
    895                         foreach (string mountPoint in volume.MountPoints) 
    896                             if (directory.FullName == mountPoint) 
    897                                 isVolumeRoot = true; 
     895                        if (volume.IsReady) 
     896                            foreach (string mountPoint in volume.MountPoints) 
     897                                if (directory.FullName == mountPoint) 
     898                                    isVolumeRoot = true; 
    898899 
    899900                    //If the folder is a mount point, then don't delete it. If it isn't, 
  • branches/eraser6/6.0/Eraser.Util/VolumeInfo.cs

    r2146 r2168  
    9191        private List<string> GetLocalVolumeMountPoints() 
    9292        { 
     93            if (!IsReady) 
     94                throw new InvalidOperationException("The volume has not been mounted or is not " + 
     95                    "currently ready."); 
     96 
    9397            List<string> result = new List<string>(); 
    9498 
     
    365369            get 
    366370            { 
     371                if (!IsReady) 
     372                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     373                        "currently ready."); 
    367374                return (DriveType)KernelApi.NativeMethods.GetDriveType(VolumeId); 
    368375            } 
     
    376383            get 
    377384            { 
     385                if (!IsReady) 
     386                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     387                        "currently ready."); 
     388 
    378389                uint clusterSize, sectorSize, freeClusters, totalClusters; 
    379390                if (KernelApi.NativeMethods.GetDiskFreeSpace(VolumeId, out clusterSize, 
     
    394405            get 
    395406            { 
     407                if (!IsReady) 
     408                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     409                        "currently ready."); 
     410 
    396411                uint clusterSize, sectorSize, freeClusters, totalClusters; 
    397412                if (KernelApi.NativeMethods.GetDiskFreeSpace(VolumeId, out clusterSize, 
     
    412427            get 
    413428            { 
     429                if (!IsReady) 
     430                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     431                        "currently ready."); 
     432 
    414433                ulong freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes; 
    415434                if (KernelApi.NativeMethods.GetDiskFreeSpaceEx(VolumeId, out freeBytesAvailable, 
     
    440459            get 
    441460            { 
     461                if (!IsReady) 
     462                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     463                        "currently ready."); 
     464 
    442465                ulong result, dummy; 
    443466                if (KernelApi.NativeMethods.GetDiskFreeSpaceEx(VolumeId, out dummy, 
     
    458481            get 
    459482            { 
     483                if (!IsReady) 
     484                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     485                        "currently ready."); 
     486 
    460487                ulong result, dummy; 
    461488                if (KernelApi.NativeMethods.GetDiskFreeSpaceEx(VolumeId, out dummy, 
     
    476503            get 
    477504            { 
     505                if (!IsReady) 
     506                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     507                        "currently ready."); 
     508 
    478509                ulong result, dummy; 
    479510                if (KernelApi.NativeMethods.GetDiskFreeSpaceEx(VolumeId, out result, 
     
    495526            get 
    496527            { 
     528                if (!IsReady) 
     529                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     530                        "currently ready."); 
     531 
    497532                List<VolumeInfo> result = new List<VolumeInfo>(); 
    498533                StringBuilder nextMountpoint = new StringBuilder( 
     
    528563            get 
    529564            { 
     565                if (!IsReady) 
     566                    throw new InvalidOperationException("The volume has not been mounted or is not " + 
     567                        "currently ready."); 
     568 
    530569                return (VolumeType == DriveType.Network ? 
    531570                    GetNetworkMountPoints() : GetLocalVolumeMountPoints()).AsReadOnly(); 
     
    538577        public bool IsMounted 
    539578        { 
    540             get { return MountPoints.Count != 0; } 
     579            get { return IsReady && MountPoints.Count != 0; } 
    541580        } 
    542581 
Note: See TracChangeset for help on using the changeset viewer.