コード例 #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);
        }
コード例 #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;
		}