Ignore:
Timestamp:
6/19/2010 10:34:05 AM (2 years ago)
Author:
lowjoel
Message:

Handle spanned drives and other dynamic volumes better. This patch allows basic dynamic volumes to be grouped under the parent physical drive.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.Util/PhysicalDriveInfo.cs

    r2206 r2207  
    8888                List<VolumeInfo> result = new List<VolumeInfo>(); 
    8989 
    90                 //Check every partition index on this drive. 
    91                 for (int i = 1; ; ++i) 
    92                 { 
    93                     string path = GetPartitionPath(i); 
    94                     using (SafeFileHandle handle = OpenWin32Device(path, 
    95                         NativeMethods.FILE_READ_ATTRIBUTES, FileShare.ReadWrite, FileOptions.None)) 
    96                     { 
    97                         if (handle.IsInvalid) 
    98                             break; 
    99                     } 
    100  
    101                     //This partition index is valid. Check which VolumeInfo this maps to. 
    102                     foreach (VolumeInfo info in VolumeInfo.Volumes) 
    103                     { 
    104                         //Only check local drives 
    105                         if (info.VolumeId.Substring(0, 4) == "\\\\?\\") 
    106                         { 
    107                             //Check whether the DOS Device maps to the target of the symbolic link 
    108                             if (NativeMethods.NtQuerySymbolicLink(path) == 
    109                                 NativeMethods.QueryDosDevice(info.VolumeId.Substring( 
    110                                     4, info.VolumeId.Length - 5))) 
    111                             { 
    112                                 //Yes, this volume belongs to this disk 
    113                                 result.Add(info); 
    114                                 break; 
    115                             } 
    116                         } 
    117                     } 
     90                //Check every volume for which disk it is on. 
     91                foreach (VolumeInfo info in VolumeInfo.Volumes) 
     92                { 
     93                    if (Equals(info.PhysicalDrive)) 
     94                        result.Add(info); 
    11895                } 
    11996 
Note: See TracChangeset for help on using the changeset viewer.