Changeset 1745 for branches/eraser6/CodeReview/Eraser.Util/VolumeInfo.cs
- Timestamp:
- 2/3/2010 3:37:13 AM (2 years ago)
- Location:
- branches/eraser6/CodeReview
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Eraser.Util/VolumeInfo.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/CodeReview
- Property svn:mergeinfo changed
/branches/eraser6/6.0 merged: 1721,1723,1730,1732,1734-1735,1737-1738,1740,1742 /trunk/eraser6 merged: 1706-1743
- Property svn:mergeinfo changed
-
branches/eraser6/CodeReview/Eraser.Util/VolumeInfo.cs
r1711 r1745 58 58 fileSystemName = new StringBuilder(NativeMethods.MaxPath * sizeof(char)); 59 59 uint serialNumber, maxComponentLength, filesystemFlags; 60 if ( !NativeMethods.GetVolumeInformation(volumeId, volumeName, NativeMethods.MaxPath,60 if (NativeMethods.GetVolumeInformation(volumeId, volumeName, NativeMethods.MaxPath, 61 61 out serialNumber, out maxComponentLength, out filesystemFlags, fileSystemName, 62 62 NativeMethods.MaxPath)) 63 63 { 64 int lastError = Marshal.GetLastWin32Error();65 switch (lastError)66 {67 case Win32ErrorCode.Success:68 case Win32ErrorCode.NotReady:69 case Win32ErrorCode.InvalidParameter: //when the volume given is not mounted.70 case Win32ErrorCode.UnrecognizedVolume:71 break;72 73 default:74 throw Win32ErrorCode.GetExceptionForWin32Error(lastError);75 }76 }77 else78 {79 64 IsReady = true; 80 VolumeLabel = volumeName.ToString(); 81 VolumeFormat = fileSystemName.ToString(); 82 83 //Determine whether it is FAT12 or FAT16 84 if (VolumeFormat == "FAT") 85 { 86 uint clusterSize, sectorSize, freeClusters, totalClusters; 87 if (NativeMethods.GetDiskFreeSpace(VolumeId, out clusterSize, 88 out sectorSize, out freeClusters, out totalClusters)) 89 { 90 if (totalClusters <= 0xFF0) 91 VolumeFormat += "12"; 92 else 93 VolumeFormat += "16"; 94 } 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 (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"; 95 83 } 96 84 }
Note: See TracChangeset
for help on using the changeset viewer.
