source: java/installer2/src/net/oni2/aeinstaller/backend/Paths.java@ 925

Last change on this file since 925 was 857, checked in by alloc, 12 years ago

AEI2.10:

  • Switched caching from Raw Depot cache to AEI packages cache (more compact, faster startup)
File size: 3.1 KB
Line 
1package net.oni2.aeinstaller.backend;
2
3import java.io.File;
4import java.io.UnsupportedEncodingException;
5import java.net.URLDecoder;
6
7/**
8 * @author Christian Illy
9 */
10public 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 String decodedPath = null;
53 try {
54 decodedPath = URLDecoder.decode(jarPath, "UTF-8");
55 } catch (UnsupportedEncodingException e) {
56 e.printStackTrace();
57 }
58 return new File(decodedPath).getParentFile().getParentFile();
59 }
60 }
61
62 /**
63 * @return Path of jar
64 */
65 public static File getJarPath() {
66 return new File(getInstallerPath(), "bin");
67 }
68
69 /**
70 * Get the preferences path
71 *
72 * @return Path
73 */
74 public static File getPrefsPath() {
75 return getInstallerPath();
76 }
77
78 /**
79 * Get the path to store downloaded files
80 *
81 * @return Download path
82 */
83 public static File getDownloadPath() {
84 return new File(getTempPath(), "downloads");
85 }
86
87 /**
88 * Get the path to store mods
89 *
90 * @return Data path
91 */
92 public static File getModsPath() {
93 return new File(getInstallerPath(), "packages");
94 }
95
96 /**
97 * Get the path where vanilla .oni-files are stored
98 *
99 * @return Vanilla .oni's path
100 */
101 public static File getVanillaOnisPath() {
102 return new File(getInstallerPath(), "vanilla");
103 }
104
105 /**
106 * Get the base path of Oni
107 *
108 * @return Vanilla Oni path
109 */
110 public static File getOniBasePath() {
111 return getInstallerPath().getParentFile().getParentFile();
112 }
113
114 /**
115 * Get the base path of the Edition
116 *
117 * @return Edition path
118 */
119 public static File getEditionBasePath() {
120 return getInstallerPath().getParentFile();
121 }
122
123 /**
124 * Get the path where the vanilla Oni GDF is located
125 *
126 * @return Vanilla Oni GDF
127 */
128 public static File getVanillaGDF() {
129 return CaseInsensitiveFile.getCaseInsensitiveFile(getOniBasePath(),
130 "GameDataFolder");
131 }
132
133 /**
134 * Get the path where the Edition GDF is located
135 *
136 * @return Edition GDF
137 */
138 public static File getEditionGDF() {
139 return new File(getEditionBasePath(), "GameDataFolder");
140 }
141
142 /**
143 * Get the systems temp-path
144 *
145 * @return Path
146 */
147 public static File getTempPath() {
148 return new File(System.getProperty("java.io.tmpdir"), "oni_aei");
149 }
150
151}
Note: See TracBrowser for help on using the repository browser.