Changeset 1733
- Timestamp:
- 1/30/2010 6:35:16 AM (3 years ago)
- Location:
- trunk/eraser6
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Eraser.Util/VolumeInfo.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6
- Property svn:mergeinfo changed
/branches/eraser6/6.0 merged: 1732
- Property svn:mergeinfo changed
-
trunk/eraser6/Eraser.Util/VolumeInfo.cs
r1731 r1733 58 58 StringBuilder fileSystemName = new StringBuilder(KernelApi.NativeMethods.MaxPath); 59 59 uint serialNumber, maxComponentLength, filesystemFlags; 60 if ( !KernelApi.NativeMethods.GetVolumeInformation(volumeId, volumeName,60 if (KernelApi.NativeMethods.GetVolumeInformation(volumeId, volumeName, 61 61 KernelApi.NativeMethods.MaxPath, out serialNumber, out maxComponentLength, 62 62 out filesystemFlags, fileSystemName, KernelApi.NativeMethods.MaxPath)) 63 63 { 64 int lastError = Marshal.GetLastWin32Error();65 switch (lastError)66 {67 case 0: //ERROR_NO_ERROR68 case 21: //ERROR_NOT_READY69 case 87: //ERROR_INVALID_PARAMETER: when the volume given is not mounted.70 case 1005: //ERROR_UNRECOGNIZED_VOLUME71 case 1392: //ERROR_FILE_CORRUPT72 break;73 74 default:75 throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());76 }77 }78 else79 {80 64 IsReady = true; 81 VolumeLabel = volumeName.ToString(); 82 VolumeFormat = fileSystemName.ToString(); 83 84 //Determine whether it is FAT12 or FAT16 85 if (VolumeFormat == "FAT") 86 { 87 uint clusterSize, sectorSize, freeClusters, totalClusters; 88 if (KernelApi.NativeMethods.GetDiskFreeSpace(VolumeId, out clusterSize, 89 out sectorSize, out freeClusters, out totalClusters)) 90 { 91 if (totalClusters <= 0xFF0) 92 VolumeFormat += "12"; 93 else 94 VolumeFormat += "16"; 95 } 65 } 66 67 //If GetVolumeInformation returns zero some of the information may 68 //have been stored, so we just try to extract it. 69 VolumeLabel = volumeName.Length == 0 ? null : volumeName.ToString(); 70 VolumeFormat = fileSystemName.Length == 0 ? null : fileSystemName.ToString(); 71 72 //Determine whether it is FAT12 or FAT16 73 if (VolumeFormat == "FAT") 74 { 75 uint clusterSize, sectorSize, freeClusters, totalClusters; 76 if (KernelApi.NativeMethods.GetDiskFreeSpace(VolumeId, out clusterSize, 77 out sectorSize, out freeClusters, out totalClusters)) 78 { 79 if (totalClusters <= 0xFF0) 80 VolumeFormat += "12"; 81 else 82 VolumeFormat += "16"; 96 83 } 97 84 }
Note: See TracChangeset
for help on using the changeset viewer.
