Changeset 2207 for trunk/eraser/Eraser.Util/PhysicalDriveInfo.cs
- Timestamp:
- 6/19/2010 10:34:05 AM (2 years ago)
- File:
-
- 1 edited
-
trunk/eraser/Eraser.Util/PhysicalDriveInfo.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Util/PhysicalDriveInfo.cs
r2206 r2207 88 88 List<VolumeInfo> result = new List<VolumeInfo>(); 89 89 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); 118 95 } 119 96
Note: See TracChangeset
for help on using the changeset viewer.
