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

Last change on this file since 1023 was 1013, checked in by alloc, 10 years ago

Fixes #85 (probably, at least from AEI side this should do it)

File size: 3.1 KB
RevLine 
[596]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 /**
[709]13 * @return Mod Depot cache filename
14 */
15 public static File getDepotCacheFilename() {
16 return new File(getPrefsPath(), "ModDepotCache.xml");
17 }
18
19 /**
[857]20 * @return Package manager cache filename
21 */
22 public static File getPacManCacheFilename() {
23 return new File(getPrefsPath(), "PacManCache.xml");
24 }
25
26 /**
[709]27 * @return Settings filename of AEI
28 */
29 public static File getSettingsFilename() {
30 return new File(getPrefsPath(), "AEI-Settings.xml");
31 }
32
33 /**
[852]34 * @return Proxy settings filename of AEI
35 */
36 public static File getProxySettingsFilename() {
37 return new File(getPrefsPath(), "AEI-ProxySettings.xml");
38 }
39
40 /**
[596]41 * Get the Jar path
42 *
43 * @return Path
44 */
45 public static File getInstallerPath() {
[852]46 if (RuntimeOptions.isDebug() || RuntimeOptions.getUseWorkingDir()) {
[625]47 String wd = System.getProperty("user.dir");
48 return new File(wd);
49 } else {
[779]50 String jarPath = Paths.class.getProtectionDomain().getCodeSource()
51 .getLocation().getPath();
[1013]52 jarPath = jarPath.replaceAll("\\+", "%2B");
[779]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();
[625]60 }
[596]61 }
62
63 /**
[776]64 * @return Path of jar
65 */
66 public static File getJarPath() {
[779]67 return new File(getInstallerPath(), "bin");
[776]68 }
69
70 /**
[596]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() {
[598]94 return new File(getInstallerPath(), "packages");
[596]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() {
[776]130 return CaseInsensitiveFile.getCaseInsensitiveFile(getOniBasePath(),
131 "GameDataFolder");
[596]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}
Note: See TracBrowser for help on using the repository browser.