| 1 | package net.oni2.aeinstaller.backend; | 
 
 
 
 
 | 2 |  | 
 
 
 
 
 | 3 | import java.io.File; | 
 
 
 
 
 | 4 | import java.io.UnsupportedEncodingException; | 
 
 
 
 
 | 5 | import java.net.URLDecoder; | 
 
 
 
 
 | 6 |  | 
 
 
 
 
 | 7 | /** | 
 
 
 
 
 | 8 | * @author Christian Illy | 
 
 
 
 
 | 9 | */ | 
 
 
 
 
 | 10 | public class Paths { | 
 
 
 
 
 | 11 |  | 
 
 
 
 
 | 12 | /** | 
 
 
 
 
 | 13 | * @return Mod Depot cache filename | 
 
 
 
 
 | 14 | */ | 
 
 
 
 
 | 15 | public static File getDepotCacheFilename() { | 
 
 
 
 
 | 16 | return new File(getPrefsPath(), "ModDepotCache.xml"); | 
 
 
 
 
 | 17 | } | 
 
 
 
 
 | 18 |  | 
 
 
 
 
 | 19 | /** | 
 
 
 
 
 | 20 | * @return Package manager cache filename | 
 
 
 
 
 | 21 | */ | 
 
 
 
 
 | 22 | public static File getPacManCacheFilename() { | 
 
 
 
 
 | 23 | return new File(getPrefsPath(), "PacManCache.xml"); | 
 
 
 
 
 | 24 | } | 
 
 
 
 
 | 25 |  | 
 
 
 
 
 | 26 | /** | 
 
 
 
 
 | 27 | * @return Settings filename of AEI | 
 
 
 
 
 | 28 | */ | 
 
 
 
 
 | 29 | public static File getSettingsFilename() { | 
 
 
 
 
 | 30 | return new File(getPrefsPath(), "AEI-Settings.xml"); | 
 
 
 
 
 | 31 | } | 
 
 
 
 
 | 32 |  | 
 
 
 
 
 | 33 | /** | 
 
 
 
 
 | 34 | * @return Proxy settings filename of AEI | 
 
 
 
 
 | 35 | */ | 
 
 
 
 
 | 36 | public static File getProxySettingsFilename() { | 
 
 
 
 
 | 37 | return new File(getPrefsPath(), "AEI-ProxySettings.xml"); | 
 
 
 
 
 | 38 | } | 
 
 
 
 
 | 39 |  | 
 
 
 
 
 | 40 | /** | 
 
 
 
 
 | 41 | * Get the Jar path | 
 
 
 
 
 | 42 | * | 
 
 
 
 
 | 43 | * @return Path | 
 
 
 
 
 | 44 | */ | 
 
 
 
 
 | 45 | public static File getInstallerPath() { | 
 
 
 
 
 | 46 | if (RuntimeOptions.isDebug() || RuntimeOptions.getUseWorkingDir()) { | 
 
 
 
 
 | 47 | String wd = System.getProperty("user.dir"); | 
 
 
 
 
 | 48 | return new File(wd); | 
 
 
 
 
 | 49 | } else { | 
 
 
 
 
 | 50 | String jarPath = Paths.class.getProtectionDomain().getCodeSource() | 
 
 
 
 
 | 51 | .getLocation().getPath(); | 
 
 
 
 
 | 52 | jarPath = jarPath.replaceAll("\\+", "%2B"); | 
 
 
 
 
 | 53 | String decodedPath = null; | 
 
 
 
 
 | 54 | try { | 
 
 
 
 
 | 55 | decodedPath = URLDecoder.decode(jarPath, "UTF-8"); | 
 
 
 
 
 | 56 | } catch (UnsupportedEncodingException e) { | 
 
 
 
 
 | 57 | e.printStackTrace(); | 
 
 
 
 
 | 58 | } | 
 
 
 
 
 | 59 | return new File(decodedPath).getParentFile().getParentFile(); | 
 
 
 
 
 | 60 | } | 
 
 
 
 
 | 61 | } | 
 
 
 
 
 | 62 |  | 
 
 
 
 
 | 63 | /** | 
 
 
 
 
 | 64 | * @return Path of jar | 
 
 
 
 
 | 65 | */ | 
 
 
 
 
 | 66 | public static File getJarPath() { | 
 
 
 
 
 | 67 | return new File(getInstallerPath(), "bin"); | 
 
 
 
 
 | 68 | } | 
 
 
 
 
 | 69 |  | 
 
 
 
 
 | 70 | /** | 
 
 
 
 
 | 71 | * Get the preferences path | 
 
 
 
 
 | 72 | * | 
 
 
 
 
 | 73 | * @return Path | 
 
 
 
 
 | 74 | */ | 
 
 
 
 
 | 75 | public static File getPrefsPath() { | 
 
 
 
 
 | 76 | return getInstallerPath(); | 
 
 
 
 
 | 77 | } | 
 
 
 
 
 | 78 |  | 
 
 
 
 
 | 79 | /** | 
 
 
 
 
 | 80 | * Get the path to store downloaded files | 
 
 
 
 
 | 81 | * | 
 
 
 
 
 | 82 | * @return Download path | 
 
 
 
 
 | 83 | */ | 
 
 
 
 
 | 84 | public static File getDownloadPath() { | 
 
 
 
 
 | 85 | return new File(getTempPath(), "downloads"); | 
 
 
 
 
 | 86 | } | 
 
 
 
 
 | 87 |  | 
 
 
 
 
 | 88 | /** | 
 
 
 
 
 | 89 | * Get the path to store mods | 
 
 
 
 
 | 90 | * | 
 
 
 
 
 | 91 | * @return Data path | 
 
 
 
 
 | 92 | */ | 
 
 
 
 
 | 93 | public static File getModsPath() { | 
 
 
 
 
 | 94 | return new File(getInstallerPath(), "packages"); | 
 
 
 
 
 | 95 | } | 
 
 
 
 
 | 96 |  | 
 
 
 
 
 | 97 | /** | 
 
 
 
 
 | 98 | * Get the path where vanilla .oni-files are stored | 
 
 
 
 
 | 99 | * | 
 
 
 
 
 | 100 | * @return Vanilla .oni's path | 
 
 
 
 
 | 101 | */ | 
 
 
 
 
 | 102 | public static File getVanillaOnisPath() { | 
 
 
 
 
 | 103 | return new File(getInstallerPath(), "vanilla"); | 
 
 
 
 
 | 104 | } | 
 
 
 
 
 | 105 |  | 
 
 
 
 
 | 106 | /** | 
 
 
 
 
 | 107 | * Get the base path of Oni | 
 
 
 
 
 | 108 | * | 
 
 
 
 
 | 109 | * @return Vanilla Oni path | 
 
 
 
 
 | 110 | */ | 
 
 
 
 
 | 111 | public static File getOniBasePath() { | 
 
 
 
 
 | 112 | return getInstallerPath().getParentFile().getParentFile(); | 
 
 
 
 
 | 113 | } | 
 
 
 
 
 | 114 |  | 
 
 
 
 
 | 115 | /** | 
 
 
 
 
 | 116 | * Get the base path of the Edition | 
 
 
 
 
 | 117 | * | 
 
 
 
 
 | 118 | * @return Edition path | 
 
 
 
 
 | 119 | */ | 
 
 
 
 
 | 120 | public static File getEditionBasePath() { | 
 
 
 
 
 | 121 | return getInstallerPath().getParentFile(); | 
 
 
 
 
 | 122 | } | 
 
 
 
 
 | 123 |  | 
 
 
 
 
 | 124 | /** | 
 
 
 
 
 | 125 | * Get the path where the vanilla Oni GDF is located | 
 
 
 
 
 | 126 | * | 
 
 
 
 
 | 127 | * @return Vanilla Oni GDF | 
 
 
 
 
 | 128 | */ | 
 
 
 
 
 | 129 | public static File getVanillaGDF() { | 
 
 
 
 
 | 130 | return CaseInsensitiveFile.getCaseInsensitiveFile(getOniBasePath(), | 
 
 
 
 
 | 131 | "GameDataFolder"); | 
 
 
 
 
 | 132 | } | 
 
 
 
 
 | 133 |  | 
 
 
 
 
 | 134 | /** | 
 
 
 
 
 | 135 | * Get the path where the Edition GDF is located | 
 
 
 
 
 | 136 | * | 
 
 
 
 
 | 137 | * @return Edition GDF | 
 
 
 
 
 | 138 | */ | 
 
 
 
 
 | 139 | public static File getEditionGDF() { | 
 
 
 
 
 | 140 | return new File(getEditionBasePath(), "GameDataFolder"); | 
 
 
 
 
 | 141 | } | 
 
 
 
 
 | 142 |  | 
 
 
 
 
 | 143 | /** | 
 
 
 
 
 | 144 | * Get the systems temp-path | 
 
 
 
 
 | 145 | * | 
 
 
 
 
 | 146 | * @return Path | 
 
 
 
 
 | 147 | */ | 
 
 
 
 
 | 148 | public static File getTempPath() { | 
 
 
 
 
 | 149 | return new File(System.getProperty("java.io.tmpdir"), "oni_aei"); | 
 
 
 
 
 | 150 | } | 
 
 
 
 
 | 151 |  | 
 
 
 
 
 | 152 | } |