Added SystemInfo and FileSystems to query system and file system information, respectively.
This commit is contained in:
@@ -54,7 +54,6 @@ public class Native {
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static <T extends NativeIntegration> T get(Class<T> type) {
|
||||
@@ -70,6 +69,17 @@ public class Native {
|
||||
if (type.equals(TerminalAccess.class)) {
|
||||
return type.cast(new TerminfoTerminalAccess());
|
||||
}
|
||||
if (type.equals(SystemInfo.class)) {
|
||||
MutableSystemInfo systemInfo = new MutableSystemInfo();
|
||||
FunctionResult result = new FunctionResult();
|
||||
NativeLibraryFunctions.getSystemInfo(systemInfo, result);
|
||||
if (result.isFailed()) {
|
||||
throw new NativeException(String.format("Could not fetch system information: %s",
|
||||
result.getMessage()));
|
||||
}
|
||||
System.out.println("=> CHARACTER ENCODING: " + systemInfo.characterEncoding);
|
||||
return type.cast(systemInfo);
|
||||
}
|
||||
} else if (platform.isWindows()) {
|
||||
if (type.equals(Process.class)) {
|
||||
return type.cast(new DefaultProcess());
|
||||
@@ -78,6 +88,11 @@ public class Native {
|
||||
return type.cast(new WindowsTerminalAccess());
|
||||
}
|
||||
}
|
||||
if (platform.isOsX()) {
|
||||
if (type.equals(FileSystems.class)) {
|
||||
return type.cast(new PosixFileSystems());
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException(String.format("Cannot load unsupported native integration %s.",
|
||||
type.getName()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user