]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - OS.java
56a5fdfd46d3691704ca15d886ba2ba6dec96a55
1 package org
.argeo
.cms
.util
;
4 import java
.nio
.file
.Path
;
5 import java
.nio
.file
.Paths
;
8 * Wrapper around system properties and portable Java APIS, for when OS specific
9 * informations are needed.
12 public final static OS LOCAL
= new OS();
14 private final String arch
, name
, version
;
16 /** The OS of the running JVM */
18 arch
= System
.getProperty("os.arch");
19 name
= System
.getProperty("os.name");
20 version
= System
.getProperty("os.version");
23 public String
getArch() {
27 public String
getName() {
31 public String
getVersion() {
35 public boolean isMSWindows() {
36 // only MS Windows would use such an horrendous separator...
37 return File
.separatorChar
== '\\';
40 public String
[] getDefaultShellCommand() {
42 return new String
[] { "/bin/bash", "-l", "-i" };
44 return new String
[] { "cmd.exe", "/C" };
47 // public static long getJvmPid() {
48 // return ProcessHandle.current().pid();
49 //// String pidAndHost = ManagementFactory.getRuntimeMXBean().getName();
50 //// return Integer.parseInt(pidAndHost.substring(0, pidAndHost.indexOf('@')));
54 * Get the runtime directory. It will be the environment variable
55 * XDG_RUNTIME_DIR if it is set, or /run if the user is 'root', or
56 * ~/.cache/argeo if not.
58 public static Path
getRunDir() {
60 String xdgRunDir
= System
.getenv("XDG_RUNTIME_DIR");
61 if (xdgRunDir
!= null) {
62 // TODO support multiple names
63 runDir
= Paths
.get(xdgRunDir
);
65 if (System
.getProperty("user.name").equals("root")) {
66 runDir
= Paths
.get("/run");
68 runDir
= Paths
.get(System
.getProperty("user.home"), ".cache/argeo");