|
1 |
| -## This is a minimal version of NetworkInterfaceControllers.jl |
| 1 | +## This is a minimal version of NetworkInterfaceControllers.jl, licensed under MIT |
2 | 2 |
|
3 | 3 | # uv_interface_address_t has a few fields, but we don't support accessing all of
|
4 | 4 | # them because `name` is the first field and it's a pointer:
|
@@ -97,29 +97,34 @@ function _get_interfaces(
|
97 | 97 | (:skip, nothing)
|
98 | 98 | end
|
99 | 99 |
|
100 |
| - # Load sysfs info |
101 |
| - sysfs_path = "/sys/class/net/$(name)" |
102 |
| - type_path = "$(sysfs_path)/type" |
103 |
| - speed_path = "$(sysfs_path)/speed" |
104 | 100 | type = nothing
|
105 |
| - if isfile(type_path) |
106 |
| - try |
107 |
| - type_code = parse(Int, read(type_path, String)) |
108 |
| - if type_code in Int.(instances(ARPHardware)) |
109 |
| - type = ARPHardware(type_code) |
| 101 | + speed = nothing |
| 102 | + |
| 103 | + @static if Sys.isunix() |
| 104 | + # Load sysfs info |
| 105 | + sysfs_path = "/sys/class/net/$(name)" |
| 106 | + type_path = "$(sysfs_path)/type" |
| 107 | + speed_path = "$(sysfs_path)/speed" |
| 108 | + |
| 109 | + if isfile(type_path) |
| 110 | + try |
| 111 | + type_code = parse(Int, read(type_path, String)) |
| 112 | + if type_code in Int.(instances(ARPHardware)) |
| 113 | + type = ARPHardware(type_code) |
| 114 | + end |
| 115 | + catch |
| 116 | + # Do nothing on any failure to read or parse the file |
110 | 117 | end
|
111 |
| - catch |
112 |
| - # Do nothing on any failure to read or parse the file |
113 | 118 | end
|
114 |
| - end |
115 |
| - speed = nothing |
116 |
| - if isfile(speed_path) |
117 |
| - try |
118 |
| - reported_speed = parse(Float64, read(speed_path, String)) |
119 |
| - if reported_speed > 0 |
120 |
| - speed = reported_speed |
| 119 | + |
| 120 | + if isfile(speed_path) |
| 121 | + try |
| 122 | + reported_speed = parse(Float64, read(speed_path, String)) |
| 123 | + if reported_speed > 0 |
| 124 | + speed = reported_speed |
| 125 | + end |
| 126 | + catch |
121 | 127 | end
|
122 |
| - catch |
123 | 128 | end
|
124 | 129 | end
|
125 | 130 |
|
|
0 commit comments