Ignore:
Timestamp:
06/13/10 06:21:46 (4 years ago)
Author:
lowjoel
Message:

Fix crash when a volume is connected but not mounted.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.