コード例 #1
0
        public static string GetExtentLabel(Volume volume, DiskExtent extent, int width)
        {
            StringBuilder builder = new StringBuilder();

            if (volume != null)
            {
                Guid?volumeGuid = WindowsVolumeHelper.GetWindowsVolumeGuid(volume);
                if (volumeGuid.HasValue)
                {
                    List <string> mountPoints = WindowsVolumeManager.GetMountPoints(volumeGuid.Value);
                    if (mountPoints.Count > 0)
                    {
                        builder.AppendLine(mountPoints[0]);
                    }
                }
            }
            long size = extent.Size;

            if (width <= 60)
            {
                builder.AppendLine(FormattingHelper.GetCompactSizeString(extent.Size));
            }
            else
            {
                builder.AppendLine(FormattingHelper.GetStandardSizeString(extent.Size));
            }
            if (volume != null)
            {
                string statusString = VolumeHelper.GetVolumeStatusString(volume);
                builder.AppendLine(statusString);
            }

            return(builder.ToString());
        }
コード例 #2
0
        public static string GetExtentsInformation(DynamicVolume volume)
        {
            List <DynamicDiskExtent> extents = volume.DynamicExtents;
            StringBuilder            builder = new StringBuilder();

            for (int extentIndex = 0; extentIndex < extents.Count; extentIndex++)
            {
                DynamicDiskExtent extent = extents[extentIndex];
                string            extentOffsetString;
                string            diskIDString = String.Empty;
                if (extent.Disk != null)
                {
                    long extentOffset = extent.FirstSector * extent.Disk.BytesPerSector;
                    extentOffsetString = FormattingHelper.GetStandardSizeString(extentOffset);
                    VolumeManagerDatabase database = VolumeManagerDatabase.ReadFromDisk(extent.Disk);
                    if (database != null)
                    {
                        ExtentRecord extentRecord = database.FindExtentByExtentID(extent.ExtentID);
                        if (extentRecord != null)
                        {
                            diskIDString = extentRecord.DiskId.ToString();
                        }
                    }
                }
                else
                {
                    extentOffsetString = "N/A";
                }

                string extentSizeString = FormattingHelper.GetStandardSizeString(extent.Size);
                builder.AppendFormat("Extent {0}, ID: {1}, Name: {2}, Size: {3}, Disk ID: {4}, Offset: {5}, Start Sector: {6}\n",
                                     extentIndex, extent.ExtentID, extent.Name, extentSizeString, diskIDString, extentOffsetString, extent.FirstSector);
            }
            return(builder.ToString());
        }
コード例 #3
0
        public static string GetVolumeInformation(Volume volume)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("Volume size: {0} bytes\n", volume.Size.ToString("###,###,###,###,##0"));
            builder.AppendFormat("Volume type: {0}\n", VolumeHelper.GetVolumeTypeString(volume));
            if (volume is GPTPartition)
            {
                builder.AppendFormat("Partition name: {0}\n", ((GPTPartition)volume).PartitionName);
            }
            else if (volume is DynamicVolume)
            {
                builder.AppendFormat("Volume name: {0}\n", ((DynamicVolume)volume).Name);
                builder.AppendFormat("Volume status: {0}\n", VolumeHelper.GetVolumeStatusString(volume));
            }

            Guid?windowsVolumeGuid = WindowsVolumeHelper.GetWindowsVolumeGuid(volume);

            if (windowsVolumeGuid.HasValue)
            {
                List <string> mountPoints = WindowsVolumeManager.GetMountPoints(windowsVolumeGuid.Value);
                foreach (string volumePath in mountPoints)
                {
                    builder.AppendFormat("Volume path: {0}\n", volumePath);
                }
                bool isMounted = WindowsVolumeManager.IsMounted(windowsVolumeGuid.Value);
                builder.AppendFormat("Mounted: {0}\n", isMounted);
            }
            builder.AppendLine();

            if (volume is MirroredVolume)
            {
                builder.AppendLine("Extents:");
                List <DynamicVolume> components = ((MirroredVolume)volume).Components;
                for (int componentIndex = 0; componentIndex < components.Count; componentIndex++)
                {
                    if (componentIndex != 0)
                    {
                        builder.AppendLine();
                    }
                    DynamicVolume component = components[componentIndex];
                    builder.AppendFormat("Component {0}:\n", componentIndex);
                    builder.Append(GetExtentsInformation(component));
                }
            }
            else if (volume is DynamicVolume)
            {
                builder.AppendLine("Extents:");
                builder.Append(GetExtentsInformation((DynamicVolume)volume));
            }
            else if (volume is Partition)
            {
                Partition partition             = (Partition)volume;
                long      partitionOffset       = partition.FirstSector * partition.BytesPerSector;
                string    partitionOffsetString = FormattingHelper.GetStandardSizeString(partitionOffset);
                builder.AppendFormat("Partiton Offset: {0}, Start Sector: {1}\n", partitionOffsetString, partition.FirstSector);
            }

            return(builder.ToString());
        }
コード例 #4
0
        public static string GetDiskLabel(Disk disk, int visualDiskIndex)
        {
            int diskNumber;

            if (disk is PhysicalDisk)
            {
                diskNumber = ((PhysicalDisk)disk).PhysicalDiskIndex;
            }
            else
            {
                diskNumber = visualDiskIndex;
            }
            string diskType = GetDiskType(disk);

            return(String.Format("Disk {0}\n{1}\n{2}", diskNumber, diskType, FormattingHelper.GetStandardSizeString(disk.Size)));
        }