mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add support for raspbian extraction (#1494)
This is how I did it in C#, and it was the most reliable way I could find.
This commit is contained in:
committed by
Peter Johnson
parent
c449ef1064
commit
f163216a4c
@@ -7,7 +7,11 @@
|
||||
|
||||
package edu.wpi.first.wpiutil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public final class RuntimeDetector {
|
||||
private static String filePrefix;
|
||||
@@ -49,6 +53,8 @@ public final class RuntimeDetector {
|
||||
filePath = "/linux/x86-64/";
|
||||
} else if (isAthena()) {
|
||||
filePath = "/linux/athena/";
|
||||
} else if (isRaspbian()) {
|
||||
filePath = "/linux/raspbian/";
|
||||
} else {
|
||||
filePath = "/linux/nativearm/";
|
||||
}
|
||||
@@ -109,6 +115,19 @@ public final class RuntimeDetector {
|
||||
return runRobotFile.exists();
|
||||
}
|
||||
|
||||
/** check if os is raspbian.
|
||||
*
|
||||
* @return if os is raspbian
|
||||
*/
|
||||
public static boolean isRaspbian() {
|
||||
try (BufferedReader reader = Files.newBufferedReader(Paths.get("/etc/os-release"))) {
|
||||
String value = reader.readLine();
|
||||
return value.contains("Raspbian");
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLinux() {
|
||||
return System.getProperty("os.name").startsWith("Linux");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user