| ... | ... | @@ -43,3 +43,19 @@ pub fn detectRuntimeVersion() WindowsVersion { |
| 43 | 43 | |
| 44 | 44 | return @intToEnum(WindowsVersion, version); |
| 45 | 45 | } |
| 46 | |
| 47 | /// Returns whether the target os versions are uniformly at least as new as the argument: |
| 48 | /// true/false if this holds for the entire target range, null if it only holds for some. |
| 49 | pub fn targetVersionIsAtLeast(requested_version: WindowsVersion) ?bool { |
| 50 | const requested = @enumToInt(requested_version); |
| 51 | const version_range = std.builtin.os.version_range.windows; |
| 52 | const target_min = @enumToInt(version_range.min); |
| 53 | const target_max = @enumToInt(version_range.max); |
| 54 | return if (target_max < requested) false else if (target_min >= requested) true else null; |
| 55 | } |
| 56 | |
| 57 | /// Returns whether the runtime os version is at least as new as the argument. |
| 58 | pub fn runtimeVersionIsAtLeast(requested_version: WindowsVersion) bool { |
| 59 | return targetVersionIsAtLeast(requested_version) orelse |
| 60 | (@enumToInt(detectRuntimeVersion()) >= @enumToInt(requested_version)); |
| 61 | } |