Ejemplo n.º 1
0
        public new static List <UsbDriveInfo> GetDrives()
        {
            var        drives = new List <UsbDriveInfo>();
            Connection conn   = Bus.System;

            var          halManagerPath = new ObjectPath("/org/freedesktop/Hal/Manager");
            const string halNameOnDbus  = "org.freedesktop.Hal";

            var manager = conn.GetObject <IHalManager>(halNameOnDbus, halManagerPath);

            ObjectPath[] volumeDevicePaths = manager.FindDeviceByCapability("volume");
            foreach (var volumeDevicePath in volumeDevicePaths)
            {
                var volumeDevice = conn.GetObject <IHalDevice>(halNameOnDbus, volumeDevicePath);

                if (DeviceIsOnUsbBus(conn, halNameOnDbus, volumeDevice))
                {
                    var deviceInfo = new UsbDriveInfoHal();
                    deviceInfo._volumeDevice = volumeDevice;
                    //This emulates Windows behavior
                    if (deviceInfo.IsReady)
                    {
                        drives.Add(deviceInfo);
                    }
                }
            }
            return(drives);
        }
Ejemplo n.º 2
0
		public new static List<UsbDriveInfo> GetDrives()
		{
			var drives = new List<UsbDriveInfo>();
			Connection conn =  Bus.System;

			var halManagerPath = new ObjectPath("/org/freedesktop/Hal/Manager");
			const string halNameOnDbus = "org.freedesktop.Hal";

			var manager = conn.GetObject<IHalManager>(halNameOnDbus, halManagerPath);

			ObjectPath[] volumeDevicePaths = manager.FindDeviceByCapability("volume");
			foreach (var volumeDevicePath in volumeDevicePaths)
			{
				var volumeDevice = conn.GetObject<IHalDevice>(halNameOnDbus, volumeDevicePath);

				if (DeviceIsOnUsbBus(conn, halNameOnDbus, volumeDevice))
				{
					var deviceInfo = new UsbDriveInfoHal();
					deviceInfo._volumeDevice = volumeDevice;
					//This emulates Windows behavior
					if (deviceInfo.IsReady)
					{
						drives.Add(deviceInfo);
					}
				}
			}
			return drives;
		}