1 package net.sf.openrocket.arch;
4 import java.util.Locale;
6 import net.sf.openrocket.util.BugException;
8 public class SystemInfo {
12 * Enumeration of supported operating systems.
14 * @see <a href="http://lopica.sourceforge.net/os.html">JNLP os and arch Value Collection</a>
15 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
17 public enum Platform {
25 * Return the current operating system.
27 * @return the operating system of the current system.
29 public static Platform getPlatform() {
30 String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
32 if (os.indexOf("win") >= 0) {
33 return Platform.WINDOWS;
34 } else if (os.indexOf("mac") >= 0) {
35 return Platform.MAC_OS;
38 * Assume UNIX otherwise, e.g. "Linux", "Solaris", "AIX" etc.
48 * Return the application data directory of this user. The location depends
49 * on the current platform.
51 * The directory will not be created by this method.
53 * @return the application directory for OpenRocket
55 public static File getUserApplicationDirectory() {
56 final String homeDir = System.getProperty("user.home");
59 switch (getPlatform()) {
61 String appdata = System.getenv("APPDATA");
62 if (appdata != null) {
63 dir = new File(appdata, "OpenRocket/");
65 dir = new File(homeDir, "OpenRocket/");
70 dir = new File(homeDir, "Library/Application Support/OpenRocket/");
74 dir = new File(homeDir, ".openrocket/");
78 throw new BugException("Not implemented for platform " + getPlatform());