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

Last change on this file since 715 was 709, checked in by alloc, 12 years ago

AEI2: Refactorings for breaking out independent features into libraries

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