diff options
Diffstat (limited to 'NET/worlds/core/SystemInfo.java')
| -rw-r--r-- | NET/worlds/core/SystemInfo.java | 49 |
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"); + } } |