Program.DetailCommand.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using DiskAccessLibrary;
  5. using DiskAccessLibrary.LogicalDiskManager;
  6. namespace ISCSIConsole
  7. {
  8. public partial class Program
  9. {
  10. public static void DetailCommand(string[] args)
  11. {
  12. if (args.Length == 2)
  13. {
  14. switch (args[1].ToLower())
  15. {
  16. case "disk":
  17. {
  18. Console.WriteLine();
  19. if (m_selectedDisk != null)
  20. {
  21. Console.WriteLine("Size: {0} bytes", m_selectedDisk.Size.ToString("###,###,###,###,##0"));
  22. if (m_selectedDisk is PhysicalDisk)
  23. {
  24. PhysicalDisk disk = (PhysicalDisk)m_selectedDisk;
  25. Console.WriteLine("Geometry: Heads: {0}, Cylinders: {1}, Sectors Per Track: {2}", disk.TracksPerCylinder, disk.Cylinders, disk.SectorsPerTrack);
  26. Console.WriteLine();
  27. }
  28. else if (m_selectedDisk is DiskImage)
  29. {
  30. DiskImage disk = (DiskImage)m_selectedDisk;
  31. Console.WriteLine("Disk image path: {0}", disk.Path);
  32. Console.WriteLine();
  33. }
  34. MasterBootRecord mbr = MasterBootRecord.ReadFromDisk(m_selectedDisk);
  35. if (mbr != null)
  36. {
  37. Console.WriteLine("Partitioning scheme: " + (mbr.IsGPTBasedDisk ? "GPT" : "MBR"));
  38. }
  39. DynamicDisk dynamicDisk = DynamicDisk.ReadFromDisk(m_selectedDisk);
  40. Console.WriteLine("Disk type: " + ((dynamicDisk != null) ? "Dynamic Disk" : "Basic Disk"));
  41. }
  42. else
  43. {
  44. Console.WriteLine("No disk has been selected.");
  45. }
  46. break;
  47. }
  48. case "volume":
  49. case "partition":
  50. {
  51. Console.WriteLine();
  52. if (m_selectedVolume != null)
  53. {
  54. Console.WriteLine("Volume size: {0} bytes", m_selectedVolume.Size.ToString("###,###,###,###,##0"));
  55. if (m_selectedVolume is GPTPartition)
  56. {
  57. Console.WriteLine("Partition name: {0}", ((GPTPartition)m_selectedVolume).PartitionName);
  58. }
  59. Guid? windowsVolumeGuid = WindowsVolumeHelper.GetWindowsVolumeGuid(m_selectedVolume);
  60. if (windowsVolumeGuid.HasValue)
  61. {
  62. List<string> mountPoints = WindowsVolumeManager.GetMountPoints(windowsVolumeGuid.Value);
  63. foreach (string volumePath in mountPoints)
  64. {
  65. Console.WriteLine("Volume path: {0}", volumePath);
  66. }
  67. bool isMounted = WindowsVolumeManager.IsMounted(windowsVolumeGuid.Value);
  68. Console.WriteLine("Mounted: {0}", isMounted);
  69. }
  70. }
  71. else
  72. {
  73. Console.WriteLine("No volume has been selected.");
  74. }
  75. break;
  76. }
  77. default:
  78. Console.WriteLine("Invalid argument.");
  79. HelpDetail();
  80. break;
  81. }
  82. }
  83. else if (args.Length > 2)
  84. {
  85. Console.WriteLine("Too many arguments.");
  86. HelpDetail();
  87. }
  88. else
  89. {
  90. HelpDetail();
  91. }
  92. }
  93. public static void HelpDetail()
  94. {
  95. Console.WriteLine();
  96. Console.WriteLine("DETAIL DISK - Display selected disk details");
  97. Console.WriteLine("DETAIL VOLUME - Display selected volume details");
  98. }
  99. }
  100. }