Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jun 11, 2024
1 parent 69b29ef commit 20447dd
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions lib/src/main/java/com/commonwealthrobotics/JvmManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,7 @@ public static String getCommandString(String project, String repo, String versio

HashMap<String, Object> database = gson.fromJson(jsonText, TT_mapStringString);
String key = "UNKNOWN";
if (LatestFromGithubLaunchUI.isLin()) {
if (LatestFromGithubLaunchUI.isArm()) {
key = "Linux-aarch64";
} else {
key = "Linux-x64";
}
}

if (LatestFromGithubLaunchUI.isMac()) {
if (LatestFromGithubLaunchUI.isArm()) {
key = "Mac-aarch64";
} else {
key = "Mac-x64";
}
}
if (LatestFromGithubLaunchUI.isWin()) {
if (LatestFromGithubLaunchUI.isArm()) {
key = "UNKNOWN";
} else {
key = "Windows-x64";
}
}
key = discoverKey(key);
Map<String, Object> vm = (Map<String, Object>) database.get(key);
String baseURL = vm.get("url").toString();
String type = vm.get("type").toString();
Expand Down Expand Up @@ -111,12 +90,39 @@ public static String getCommandString(String project, String repo, String versio
return cmd + " -jar ";
}

public static boolean isExecutable(ZipArchiveEntry entry) {
int unixMode = entry.getUnixMode();
// Check if any of the executable bits are set for user, group, or others.
// User executable: 0100 (0x40), Group executable: 0010 (0x10), Others executable: 0001 (0x01)
return (unixMode & 0x49) != 0;
}
private static String discoverKey(String key) {
if (LatestFromGithubLaunchUI.isLin()) {
if (LatestFromGithubLaunchUI.isArm()) {
key = "Linux-aarch64";
} else {
key = "Linux-x64";
}
}

if (LatestFromGithubLaunchUI.isMac()) {
if (LatestFromGithubLaunchUI.isArm()) {
key = "Mac-aarch64";
} else {
key = "Mac-x64";
}
}
if (LatestFromGithubLaunchUI.isWin()) {
if (LatestFromGithubLaunchUI.isArm()) {
key = "UNKNOWN";
} else {
key = "Windows-x64";
}
}
return key;
}

public static boolean isExecutable(ZipArchiveEntry entry) {
int unixMode = entry.getUnixMode();
// Check if any of the executable bits are set for user, group, or others.
// User executable: 0100 (0x40), Group executable: 0010 (0x10), Others
// executable: 0001 (0x01)
return (unixMode & 0x49) != 0;
}
private static void unzip(File path, String dir) throws Exception {
String fileBaseName = FilenameUtils.getBaseName(path.getName().toString());
Path destFolderPath = new File(dir).toPath();
Expand Down

0 comments on commit 20447dd

Please sign in to comment.