Changeset 2186
- Timestamp:
- 6/18/2010 11:32:18 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/eraser/Eraser.Util/PhysicalDriveInfo.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Util/PhysicalDriveInfo.cs
r2184 r2186 65 65 for (int i = 0; ; ++i) 66 66 { 67 string path = string.Format(CultureInfo.InvariantCulture, 68 "\\Device\\Harddisk{0}\\Partition0", i); 69 using (SafeFileHandle handle = OpenWin32Device(path)) 67 using (SafeFileHandle handle = OpenWin32Device(GetDiskPath(i))) 70 68 { 71 69 if (handle.IsInvalid) 72 70 break; 71 } 73 72 74 result.Add(new PhysicalDriveInfo(i)); 75 } 73 result.Add(new PhysicalDriveInfo(i)); 76 74 } 77 75 … … 132 130 for (int i = 1; ; ++i) 133 131 { 134 string path = string.Format(CultureInfo.InvariantCulture, 135 "\\Device\\Harddisk{0}\\Partition{1}", Index, i); 132 string path = GetPartitionPath(i); 136 133 using (SafeFileHandle handle = OpenWin32Device(path)) 137 134 { … … 162 159 } 163 160 } 161 162 /// <summary> 163 /// The format string for accessing partitions. 164 /// </summary> 165 private static readonly string PartitionFormat = "\\Device\\Harddisk{0}\\Partition{1}"; 166 167 /// <summary> 168 /// Gets the disk device name. 169 /// </summary> 170 /// <param name="disk">The zero-based disk index.</param> 171 /// <returns>The device name of the disk.</returns> 172 private static string GetDiskPath(int disk) 173 { 174 return string.Format(CultureInfo.InvariantCulture, PartitionFormat, disk, 0); 175 } 176 177 /// <summary> 178 /// Gets the current disk device name. 179 /// </summary> 180 /// <returns>The device name of the disk.</returns> 181 private string GetDiskPath() 182 { 183 return GetDiskPath(Index); 184 } 185 186 /// <summary> 187 /// Gets the partition device name. 188 /// </summary> 189 /// <param name="partition">The one-based partition index.</param> 190 /// <returns>The device name of the partition.</returns> 191 private string GetPartitionPath(int partition) 192 { 193 return string.Format(CultureInfo.InvariantCulture, PartitionFormat, Index, partition); 194 } 164 195 } 165 196 }
Note: See TracChangeset
for help on using the changeset viewer.
