summaryrefslogtreecommitdiff
path: root/NET/worlds/core/SystemInfo.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-13 02:05:49 -0800
committerFuwn <[email protected]>2026-02-13 02:05:49 -0800
commit9817c9b1647faaa1ffe4af5a7620a8602651f438 (patch)
treeff22dd2e017565aadc146062f0c7064e74035df2 /NET/worlds/core/SystemInfo.java
parentfix: Decompilation artifact repairs for Java 11 compilation (diff)
downloadworldsplayer-9817c9b1647faaa1ffe4af5a7620a8602651f438.tar.xz
worldsplayer-9817c9b1647faaa1ffe4af5a7620a8602651f438.zip
feat: Reimplement core I/O and system information native methods with pure Java
- FastDataInput: DataInputStream wrapper replacing native binary I/O - DNSLookup: InetAddress.getAllByName() replacing native gethostbyname() - Restorer: Array.newInstance() replacing native makeArray() - SystemInfo: Runtime/File APIs for disk, memory, CPU, platform info - StatMemNode: Runtime APIs for memory status reporting
Diffstat (limited to 'NET/worlds/core/SystemInfo.java')
-rw-r--r--NET/worlds/core/SystemInfo.java49
1 files changed, 39 insertions, 10 deletions
diff --git a/NET/worlds/core/SystemInfo.java b/NET/worlds/core/SystemInfo.java
index ceb2a7f..8a138aa 100644
--- a/NET/worlds/core/SystemInfo.java
+++ b/NET/worlds/core/SystemInfo.java
@@ -88,27 +88,56 @@ public class SystemInfo implements MainCallback, MainTerminalCallback {
return "[" + Std.getRealTime() + "] ";
}
- public static native int GetDiskFreeSpace(String var0);
+ public static int GetDiskFreeSpace(String var0) {
+ try {
+ java.io.File file = (var0 != null) ? new java.io.File(var0) : new java.io.File(".");
+
+ return (int)(file.getFreeSpace() / 1024L);
+ } catch (Exception e) {
+ return 0;
+ }
+ }
public static int GetDiskFreeSpace() {
return GetDiskFreeSpace(null);
}
- public static native String GetSystemDirectory();
+ public static String GetSystemDirectory() {
+ return System.getProperty("java.home", "");
+ }
- public static native String GetCurrentDirectory();
+ public static String GetCurrentDirectory() {
+ return System.getProperty("user.dir", "");
+ }
- public static native int GetTotalPhysicalMemory();
+ public static int GetTotalPhysicalMemory() {
+ return (int)(Runtime.getRuntime().maxMemory() / 1024L);
+ }
- public static native int GetAvailPhysicalMemory();
+ public static int GetAvailPhysicalMemory() {
+ return (int)(Runtime.getRuntime().freeMemory() / 1024L);
+ }
- public static native int GetTotalPagedMemory();
+ public static int GetTotalPagedMemory() {
+ return (int)(Runtime.getRuntime().totalMemory() / 1024L);
+ }
- public static native int GetAvailPagedMemory();
+ public static int GetAvailPagedMemory() {
+ Runtime runtime = Runtime.getRuntime();
+ long availableMemory = runtime.maxMemory() - (runtime.totalMemory() - runtime.freeMemory());
+
+ return (int)(availableMemory / 1024L);
+ }
- public static native String GetPlatformID();
+ public static String GetPlatformID() {
+ return System.getProperty("os.name", "Unknown") + " " + System.getProperty("os.version", "");
+ }
- public static native int GetNumberOfProcessors();
+ public static int GetNumberOfProcessors() {
+ return Runtime.getRuntime().availableProcessors();
+ }
- public static native String GetProcessorType();
+ public static String GetProcessorType() {
+ return System.getProperty("os.arch", "Unknown");
+ }
}