[udev] Read property on UdevDevice
This commit is contained in:
parent
2a64755b76
commit
cf27a056b8
2 changed files with 19 additions and 0 deletions
17
udev.cpp
17
udev.cpp
|
@ -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
2
udev.h
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue