/// <summary> /// Returns the readable partitions as folders on the drive /// </summary> public Folder[] Get(FATXDrive xDrive) { List<Folder> PIList = new List<Folder>(); if (xDrive.DriveType == Info.DriveType.HDD | xDrive.DriveType == Info.DriveType.Backup) { foreach (Info.HDDFATX.Partitions e in Enum.GetValues(typeof(Info.HDDFATX.Partitions))) { if (e == Info.HDDFATX.Partitions.Data | e == Info.HDDFATX.Partitions.Compatibility) { FATStuff FS = new FATStuff(xDrive, e); if (FS.Magic() == "XTAF") { PartitionInfo PI = new PartitionInfo(); PI.ClusterSize = FS.ClusterSize(); PI.DataOffset = FS.DataOffset(); PI.FATCopies = FS.FATCopies(); PI.FATOffset = FS.FATOffset; PI.FATSize = FS.FATSize(); PI.ID = FS.PartitionID(); PI.Magic = FS.Magic(); PI.Name = e.ToString(); PI.Offset = (long)e; PI.SectorsPerCluster = FS.SectorsPerCluster(); PI.EntrySize = FS.bit; PI.Size = FS.PartitionSize(); Folder f = new Folder(xDrive, PI); f.EData.StartingCluster = 0; PIList.Add(f); } } } if (PIList.Count == 0) { FATStuff FS = new FATStuff(xDrive, (long)0); if (FS.Magic() == "XTAF") { PartitionInfo PI = new PartitionInfo(); PI.ClusterSize = FS.ClusterSize(); PI.DataOffset = FS.DataOffset(); PI.FATCopies = FS.FATCopies(); PI.FATOffset = FS.FATOffset; PI.FATSize = FS.FATSize(); PI.ID = FS.PartitionID(); PI.Magic = FS.Magic(); PI.Name = "Root"; PI.Offset = 0x0; PI.SectorsPerCluster = FS.SectorsPerCluster(); PI.EntrySize = FS.bit; PI.Size = xDrive.DriveSize; Folder f = new Folder(xDrive, PI); PIList.Add(f); } } } else if (xDrive.DriveType == Info.DriveType.USB) { foreach (Info.USBOffsets e in Enum.GetValues(typeof(Info.USBOffsets))) { FATStuff FS = new FATStuff(xDrive, (long)e); if (FS.Magic() == "XTAF") { PartitionInfo PI = new PartitionInfo(); PI.ClusterSize = FS.ClusterSize(); PI.DataOffset = FS.DataOffset(); PI.FATCopies = FS.FATCopies(); PI.FATOffset = FS.FATOffset; PI.FATSize = FS.FATSize(); PI.ID = FS.PartitionID(); PI.Magic = FS.Magic(); PI.Name = e.ToString(); PI.Offset = (long)e; PI.SectorsPerCluster = FS.SectorsPerCluster(); PI.EntrySize = FS.bit; PI.Size = FS.PartitionSize(); Folder f = new Folder(xDrive, PI); f.EData.StartingCluster = 0; PIList.Add(f); } } } else if (PIList.Count == 0) { if (System.Windows.Forms.MessageBox.Show("No partitions were found. Would you like to use the Manual Partition tool to set the offset yourself?", "No Partitions Found", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { PartitionInfo PI = new PartitionInfo(); Manual_Partition mp = new Manual_Partition(ref PI); if (mp.ShowDialog() == System.Windows.Forms.DialogResult.OK) { PI = mp.ReturnInfo; FATStuff FS = new FATStuff(xDrive, PI.Offset); if (FS.Magic() == "XTAF") { PI.ClusterSize = FS.ClusterSize(); PI.DataOffset = FS.DataOffset(); PI.FATCopies = FS.FATCopies(); PI.FATOffset = FS.FATOffset; PI.FATSize = FS.FATSize(); PI.ID = FS.PartitionID(); PI.Magic = FS.Magic(); PI.Name = "Root"; PI.SectorsPerCluster = FS.SectorsPerCluster(); PI.EntrySize = FS.bit; PI.Size = FS.PartitionSize(); Folder f = new Folder(xDrive, PI); f.EData.StartingCluster = 0; PIList.Add(f); } } } } return PIList.ToArray(); }