[udev] Read property on UdevDevice

This commit is contained in:
Martin Gräßlin 2015-04-23 15:07:30 +02:00
parent 2a64755b76
commit cf27a056b8
2 changed files with 19 additions and 0 deletions

View file

@ -189,4 +189,21 @@ int UdevDevice::sysNum() const
return QByteArray(udev_device_get_sysnum(m_device)).toInt();
}
const char *UdevDevice::property(const char *key)
{
if (!m_device) {
return nullptr;
}
return udev_device_get_property_value(m_device, key);
}
bool UdevDevice::hasProperty(const char *key, const char *value)
{
const char *p = property(key);
if (!p) {
return false;
}
return qstrcmp(p, value) == 0;
}
}

2
udev.h
View file

@ -37,6 +37,8 @@ public:
udev_device *getParentWithSubsystemDevType(const char *subsystem, const char *devtype = nullptr) const;
const char *devNode();
int sysNum() const;
const char *property(const char *key);
bool hasProperty(const char *key, const char *value);
operator udev_device*() const {
return m_device;