1 package net.sf.openrocket.arch;
5 import net.sf.openrocket.util.BugException;
7 public class SystemInfo {
11 * Enumeration of supported operating systems.
13 * @see <a href="http://lopica.sourceforge.net/os.html">JNLP os and arch Value Collection</a>
14 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
16 public enum Platform {
24 * Return the current operating system.
26 * @return the operating system of the current system.
28 public static Platform getPlatform() {
29 String os = System.getProperty("os.name").toLowerCase();
31 if (os.indexOf("win") >= 0) {
32 return Platform.WINDOWS;
33 } else if (os.indexOf("mac") >= 0) {
34 return Platform.MAC_OS;
37 * Assume UNIX otherwise, e.g. "Linux", "Solaris", "AIX" etc.
47 * Return the application data directory of this user. The location depends
48 * on the current platform.
50 * The directory will not be created by this method.
52 * @return the application directory for OpenRocket
54 public static File getUserApplicationDirectory() {
55 final String homeDir = System.getProperty("user.home");
58 switch (getPlatform()) {
60 String appdata = System.getenv("APPDATA");
61 if (appdata != null) {
62 dir = new File(appdata, "OpenRocket/");
64 dir = new File(homeDir, "OpenRocket/");
69 dir = new File(homeDir, "Library/Application Support/OpenRocket/");
73 dir = new File(homeDir, ".openrocket/");
77 throw new BugException("Not implemented for platform " + getPlatform());