]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/util/OS.java
1 package org
.argeo
.cms
.util
;
4 import java
.nio
.file
.Path
;
5 import java
.nio
.file
.Paths
;
7 /** When OS specific informations are needed. */
9 public final static OS LOCAL
= new OS();
11 private final String arch
, name
, version
;
13 /** The OS of the running JVM */
15 arch
= System
.getProperty("os.arch");
16 name
= System
.getProperty("os.name");
17 version
= System
.getProperty("os.version");
20 public String
getArch() {
24 public String
getName() {
28 public String
getVersion() {
32 public boolean isMSWindows() {
33 // only MS Windows would use such an horrendous separator...
34 return File
.separatorChar
== '\\';
37 public String
[] getDefaultShellCommand() {
39 return new String
[] { "/bin/bash", "-l", "-i" };
41 return new String
[] { "cmd.exe", "/C" };
44 public static long getJvmPid() {
45 return ProcessHandle
.current().pid();
46 // String pidAndHost = ManagementFactory.getRuntimeMXBean().getName();
47 // return Integer.parseInt(pidAndHost.substring(0, pidAndHost.indexOf('@')));
51 * Get the runtime directory. It will be the environment variable
52 * XDG_RUNTIME_DIR if it is set, or ~/.cache/argeo if not.
54 public static Path
getRunDir() {
56 String xdgRunDir
= System
.getenv("XDG_RUNTIME_DIR");
57 if (xdgRunDir
!= null) {
58 // TODO support multiple names
59 runDir
= Paths
.get(xdgRunDir
);
61 runDir
= Paths
.get(System
.getProperty("user.home"), ".cache/argeo");