aboutsummaryrefslogtreecommitdiffstats
path: root/setupapi/types_windows.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-06 20:17:47 +0100
committerSimon Rozman <simon@rozman.si>2019-02-06 20:17:47 +0100
commit069016bbc4fac01260f2addd70b67bce5ebeac70 (patch)
treede727571cbce16ada46f314a286343dea13a73ac /setupapi/types_windows.go
parentsetupapi: Make toUTF16() public and add UTF16ToBuf() counterpart (diff)
downloadwireguard-go-069016bbc4fac01260f2addd70b67bce5ebeac70.tar.xz
wireguard-go-069016bbc4fac01260f2addd70b67bce5ebeac70.zip
setupapi: Add SP_DRVINFO_DATA.IsNewer() method to simplify comparison
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to '')
-rw-r--r--setupapi/types_windows.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/setupapi/types_windows.go b/setupapi/types_windows.go
index 0eb640c..2dfcb70 100644
--- a/setupapi/types_windows.go
+++ b/setupapi/types_windows.go
@@ -321,6 +321,32 @@ func (data SP_DRVINFO_DATA) ToGo() *DrvInfoData {
}
}
+// IsNewer method returns true if SP_DRVINFO_DATA date and version is newer than supplied parameters.
+func (data SP_DRVINFO_DATA) IsNewer(DriverDate windows.Filetime, DriverVersion uint64) bool {
+ if data.DriverDate.HighDateTime > DriverDate.HighDateTime {
+ return true
+ }
+ if data.DriverDate.HighDateTime < DriverDate.HighDateTime {
+ return false
+ }
+
+ if data.DriverDate.LowDateTime > DriverDate.LowDateTime {
+ return true
+ }
+ if data.DriverDate.LowDateTime < DriverDate.LowDateTime {
+ return false
+ }
+
+ if data.DriverVersion > DriverVersion {
+ return true
+ }
+ if data.DriverVersion < DriverVersion {
+ return false
+ }
+
+ return false
+}
+
// DrvInfoData is driver information structure (member of a driver info list that may be associated with a particular device instance, or (globally) with a device information set)
type DrvInfoData struct {
DriverType uint32