1
2
3
4
5 package oshi.util.platform.linux;
6
7 import java.io.File;
8
9 import oshi.annotation.concurrent.ThreadSafe;
10 import oshi.util.GlobalConfig;
11
12
13
14
15
16
17
18 @ThreadSafe
19 public final class SysPath {
20
21
22
23
24 public static final String SYS = querySysConfig() + "/";
25
26 public static final String CPU = SYS + "devices/system/cpu/";
27 public static final String DMI_ID = SYS + "devices/virtual/dmi/id/";
28 public static final String NET = SYS + "class/net/";
29 public static final String MODEL = SYS + "firmware/devicetree/base/model";
30 public static final String POWER_SUPPLY = SYS + "class/power_supply";
31 public static final String HWMON = SYS + "class/hwmon/";
32 public static final String THERMAL = SYS + "class/thermal/thermal_zone";
33
34 private SysPath() {
35 }
36
37 private static String querySysConfig() {
38 String sysPath = GlobalConfig.get(GlobalConfig.OSHI_UTIL_SYS_PATH, "/sys");
39
40 sysPath = '/' + sysPath.replaceAll("/$|^/", "");
41 if (!new File(sysPath).exists()) {
42 throw new GlobalConfig.PropertyException(GlobalConfig.OSHI_UTIL_SYS_PATH, "The path does not exist");
43 }
44 return sysPath;
45 }
46 }