Added SystemInfo and FileSystems to query system and file system information, respectively.

This commit is contained in:
Adam Murdoch
2012-08-12 06:17:58 +10:00
parent 5f3761dd41
commit 3a58e27eeb
18 changed files with 612 additions and 327 deletions

View File

@@ -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()));
}