@@ -43,6 +43,10 @@ public static void main(String[] args) {
4343 System .out .println (expanduser (argument ));
4444 } else if (command .equals ("canonical" )) {
4545 System .out .println (canonical (argument ));
46+ } else if (command .equals ("parent" )) {
47+ System .out .println (parent (argument ));
48+ } else if (command .equals ("root" )) {
49+ System .out .println (root (argument ));
4650 } else if (command .equals ("is_absolute" )) {
4751 System .out .println (is_absolute (argument ));
4852 } else if (command .equals ("is_exe" )) {
@@ -51,6 +55,10 @@ public static void main(String[] args) {
5155 System .out .println (is_readable (argument ));
5256 } else if (command .equals ("ram_free" )) {
5357 System .out .println (ram_free ());
58+ } else if (command .equals ("cpu_count" )) {
59+ System .out .println (cpu_count ());
60+ } else if (command .equals ("cpu_load" )) {
61+ System .out .println (cpu_load ());
5462 } else {
5563 System .err .println ("Command not found" );
5664 }
@@ -93,9 +101,31 @@ public static Boolean is_readable(String path) {
93101 return new File (path ).canRead ();
94102 }
95103
104+ public static String parent (String path ) {
105+ File f = new File (path );
106+ return f .getParent ();
107+ }
108+
109+ public static String root (String path ) {
110+ File f = new File (path );
111+ return f .toPath ().getRoot ().toString ();
112+ }
113+
96114 public static Long ram_free () {
97115 com .sun .management .OperatingSystemMXBean os = (com .sun .management .OperatingSystemMXBean )
98116 java .lang .management .ManagementFactory .getOperatingSystemMXBean ();
99117 return os .getFreeMemorySize ();
100118 }
119+
120+ public static int cpu_count () {
121+ com .sun .management .OperatingSystemMXBean os = (com .sun .management .OperatingSystemMXBean )
122+ java .lang .management .ManagementFactory .getOperatingSystemMXBean ();
123+ return os .getAvailableProcessors ();
124+ }
125+
126+ public static double cpu_load () {
127+ com .sun .management .OperatingSystemMXBean os = (com .sun .management .OperatingSystemMXBean )
128+ java .lang .management .ManagementFactory .getOperatingSystemMXBean ();
129+ return os .getCpuLoad ();
130+ }
101131}
0 commit comments