package net.oni2.aeinstaller.backend; import java.io.File; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; /** * @author Christian Illy */ public class Paths { /** * Get the Jar path * * @return Path */ public static File getInstallerPath() { if (Settings.isDebug()) { String wd = System.getProperty("user.dir"); return new File(wd); } else { String jarPath = Settings.class.getProtectionDomain() .getCodeSource().getLocation().getPath(); String decodedPath = null; try { decodedPath = URLDecoder.decode(jarPath, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return new File(decodedPath).getParentFile(); } } /** * Get the preferences path * * @return Path */ public static File getPrefsPath() { return getInstallerPath(); } /** * Get the path to store downloaded files * * @return Download path */ public static File getDownloadPath() { return new File(getTempPath(), "downloads"); } /** * Get the path to store mods * * @return Data path */ public static File getModsPath() { return new File(getInstallerPath(), "packages"); } /** * Get the path where vanilla .oni-files are stored * * @return Vanilla .oni's path */ public static File getVanillaOnisPath() { return new File(getInstallerPath(), "vanilla"); } /** * Get the base path of Oni * * @return Vanilla Oni path */ public static File getOniBasePath() { return getInstallerPath().getParentFile().getParentFile(); } /** * Get the base path of the Edition * * @return Edition path */ public static File getEditionBasePath() { return getInstallerPath().getParentFile(); } /** * Get the path where the vanilla Oni GDF is located * * @return Vanilla Oni GDF */ public static File getVanillaGDF() { return new File(getOniBasePath(), "GameDataFolder"); } /** * Get the path where the Edition GDF is located * * @return Edition GDF */ public static File getEditionGDF() { return new File(getEditionBasePath(), "GameDataFolder"); } /** * Get the systems temp-path * * @return Path */ public static File getTempPath() { return new File(System.getProperty("java.io.tmpdir"), "oni_aei"); } }