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

Last change on this file since 856 was 852, checked in by alloc, 12 years ago

AEI2.08, AEIUpdater:

File size: 2.9 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 Settings filename of AEI
21 */
22 public static File getSettingsFilename() {
23 return new File(getPrefsPath(), "AEI-Settings.xml");
24 }
25
26 /**
27 * @return Proxy settings filename of AEI
28 */
29 public static File getProxySettingsFilename() {
30 return new File(getPrefsPath(), "AEI-ProxySettings.xml");
31 }
32
33 /**
34 * Get the Jar path
35 *
36 * @return Path
37 */
38 public static File getInstallerPath() {
39 if (RuntimeOptions.isDebug() || RuntimeOptions.getUseWorkingDir()) {
40 String wd = System.getProperty("user.dir");
41 return new File(wd);
42 } else {
43 String jarPath = Paths.class.getProtectionDomain().getCodeSource()
44 .getLocation().getPath();
45 String decodedPath = null;
46 try {
47 decodedPath = URLDecoder.decode(jarPath, "UTF-8");
48 } catch (UnsupportedEncodingException e) {
49 e.printStackTrace();
50 }
51 return new File(decodedPath).getParentFile().getParentFile();
52 }
53 }
54
55 /**
56 * @return Path of jar
57 */
58 public static File getJarPath() {
59 return new File(getInstallerPath(), "bin");
60 }
61
62 /**
63 * Get the preferences path
64 *
65 * @return Path
66 */
67 public static File getPrefsPath() {
68 return getInstallerPath();
69 }
70
71 /**
72 * Get the path to store downloaded files
73 *
74 * @return Download path
75 */
76 public static File getDownloadPath() {
77 return new File(getTempPath(), "downloads");
78 }
79
80 /**
81 * Get the path to store mods
82 *
83 * @return Data path
84 */
85 public static File getModsPath() {
86 return new File(getInstallerPath(), "packages");
87 }
88
89 /**
90 * Get the path where vanilla .oni-files are stored
91 *
92 * @return Vanilla .oni's path
93 */
94 public static File getVanillaOnisPath() {
95 return new File(getInstallerPath(), "vanilla");
96 }
97
98 /**
99 * Get the base path of Oni
100 *
101 * @return Vanilla Oni path
102 */
103 public static File getOniBasePath() {
104 return getInstallerPath().getParentFile().getParentFile();
105 }
106
107 /**
108 * Get the base path of the Edition
109 *
110 * @return Edition path
111 */
112 public static File getEditionBasePath() {
113 return getInstallerPath().getParentFile();
114 }
115
116 /**
117 * Get the path where the vanilla Oni GDF is located
118 *
119 * @return Vanilla Oni GDF
120 */
121 public static File getVanillaGDF() {
122 return CaseInsensitiveFile.getCaseInsensitiveFile(getOniBasePath(),
123 "GameDataFolder");
124 }
125
126 /**
127 * Get the path where the Edition GDF is located
128 *
129 * @return Edition GDF
130 */
131 public static File getEditionGDF() {
132 return new File(getEditionBasePath(), "GameDataFolder");
133 }
134
135 /**
136 * Get the systems temp-path
137 *
138 * @return Path
139 */
140 public static File getTempPath() {
141 return new File(System.getProperty("java.io.tmpdir"), "oni_aei");
142 }
143
144}
Note: See TracBrowser for help on using the repository browser.