/// <summary> /// Gets a list of Devices that can be selected /// </summary> /// <param name="onlyRemoveable"> If set to false also Fixed devices will be included in the list (most likely useless) </param> /// <returns> List of devices used for the MMC Flasher </returns> internal static IList <MMCDevice> GetDevices(bool onlyRemoveable = true) { var tmp = new Dictionary <int, MMCDevice>(); foreach (var drive in DriveInfo.GetDrives()) { if (drive.DriveType == DriveType.Fixed && onlyRemoveable) { continue; } if (drive.DriveType != DriveType.Removable && drive.DriveType != DriveType.Fixed) { continue; } try { var devnum = NativeWin32.GetDeviceNumber(drive.Name); if (!tmp.ContainsKey(devnum)) { var path = NativeWin32.GetDevicePath(drive.Name); tmp.Add(devnum, new MMCDevice(drive.Name, path, NativeWin32.GetGeometryEX(path))); } else { tmp[devnum].DisplayName = string.Format("{0}, {1}", tmp[devnum].DisplayName, drive.Name); tmp[devnum].AddVolume(drive.Name); } } catch (Exception ex) { var dex = ex as X360NANDManagerException; if (dex != null && (dex.Win32ErrorNumber == 32 || dex.Win32ErrorNumber == 0 /* Success, not an error?! */ || dex.Win32ErrorNumber == 21 /* Device not ready... ignore it... */)) { continue; } var wex = ex as Win32Exception; if (wex != null && wex.NativeErrorCode == 21) //Device not ready, Win32 Error outside of my own error handling... { continue; } throw; } } Main.SendDebug("Copying data to returnable object"); var ret = new MMCDevice[tmp.Values.Count]; tmp.Values.CopyTo(ret, 0); return(ret); }
/// <summary> /// Gets a list of Devices that can be selected /// </summary> /// <param name="onlyRemoveable"> If set to false also Fixed devices will be included in the list (most likely useless) </param> /// <returns> List of devices used for the MMC Flasher </returns> internal static IList <MMCDevice> GetDevices(bool onlyRemoveable = true) { var tmp = new Dictionary <int, MMCDevice>(); foreach (var drive in DriveInfo.GetDrives()) { if (drive.DriveType == DriveType.Fixed && onlyRemoveable) { continue; } if (drive.DriveType != DriveType.Removable && drive.DriveType != DriveType.Fixed) { continue; } try { Main.SendDebug(string.Format("Getting Drive number for Device: {0}", drive.Name)); var devnum = NativeWin32.GetDeviceNumber(drive.Name); if (!tmp.ContainsKey(devnum)) { Main.SendDebug(string.Format("Getting Drive path for Device: {0}", drive.Name)); var path = NativeWin32.GetDevicePath(drive.Name); Main.SendDebug(string.Format("Getting Drive Geometry for Device: {0}", drive.Name)); tmp.Add(devnum, new MMCDevice(drive.Name, path, NativeWin32.GetGeometry(path))); } else { tmp[devnum].DisplayName = string.Format("{0}, {1}", tmp[devnum].DisplayName, drive.Name); } } catch (Exception ex) { var dex = ex as DeviceError; if (dex != null && dex.Win32ErrorNumber == 32) { continue; } throw; } } Main.SendDebug("Copying data to returnable object"); var ret = new MMCDevice[tmp.Values.Count]; tmp.Values.CopyTo(ret, 0); return(ret); }