Skip to content

Commit 20447dd

Browse files
committed
refactor
1 parent 69b29ef commit 20447dd

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

lib/src/main/java/com/commonwealthrobotics/JvmManager.java

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,7 @@ public static String getCommandString(String project, String repo, String versio
5959

6060
HashMap<String, Object> database = gson.fromJson(jsonText, TT_mapStringString);
6161
String key = "UNKNOWN";
62-
if (LatestFromGithubLaunchUI.isLin()) {
63-
if (LatestFromGithubLaunchUI.isArm()) {
64-
key = "Linux-aarch64";
65-
} else {
66-
key = "Linux-x64";
67-
}
68-
}
69-
70-
if (LatestFromGithubLaunchUI.isMac()) {
71-
if (LatestFromGithubLaunchUI.isArm()) {
72-
key = "Mac-aarch64";
73-
} else {
74-
key = "Mac-x64";
75-
}
76-
}
77-
if (LatestFromGithubLaunchUI.isWin()) {
78-
if (LatestFromGithubLaunchUI.isArm()) {
79-
key = "UNKNOWN";
80-
} else {
81-
key = "Windows-x64";
82-
}
83-
}
62+
key = discoverKey(key);
8463
Map<String, Object> vm = (Map<String, Object>) database.get(key);
8564
String baseURL = vm.get("url").toString();
8665
String type = vm.get("type").toString();
@@ -111,12 +90,39 @@ public static String getCommandString(String project, String repo, String versio
11190
return cmd + " -jar ";
11291
}
11392

114-
public static boolean isExecutable(ZipArchiveEntry entry) {
115-
int unixMode = entry.getUnixMode();
116-
// Check if any of the executable bits are set for user, group, or others.
117-
// User executable: 0100 (0x40), Group executable: 0010 (0x10), Others executable: 0001 (0x01)
118-
return (unixMode & 0x49) != 0;
119-
}
93+
private static String discoverKey(String key) {
94+
if (LatestFromGithubLaunchUI.isLin()) {
95+
if (LatestFromGithubLaunchUI.isArm()) {
96+
key = "Linux-aarch64";
97+
} else {
98+
key = "Linux-x64";
99+
}
100+
}
101+
102+
if (LatestFromGithubLaunchUI.isMac()) {
103+
if (LatestFromGithubLaunchUI.isArm()) {
104+
key = "Mac-aarch64";
105+
} else {
106+
key = "Mac-x64";
107+
}
108+
}
109+
if (LatestFromGithubLaunchUI.isWin()) {
110+
if (LatestFromGithubLaunchUI.isArm()) {
111+
key = "UNKNOWN";
112+
} else {
113+
key = "Windows-x64";
114+
}
115+
}
116+
return key;
117+
}
118+
119+
public static boolean isExecutable(ZipArchiveEntry entry) {
120+
int unixMode = entry.getUnixMode();
121+
// Check if any of the executable bits are set for user, group, or others.
122+
// User executable: 0100 (0x40), Group executable: 0010 (0x10), Others
123+
// executable: 0001 (0x01)
124+
return (unixMode & 0x49) != 0;
125+
}
120126
private static void unzip(File path, String dir) throws Exception {
121127
String fileBaseName = FilenameUtils.getBaseName(path.getName().toString());
122128
Path destFolderPath = new File(dir).toPath();

0 commit comments

Comments
 (0)