source: java/AEInstaller2-Updater/src/net/oni2/aeinstaller/updater/backend/Paths.java@ 1043

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

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

File size: 1.5 KB
Line 
1package net.oni2.aeinstaller.updater.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 * Use the wd instead of the jar path
14 */
15 public static boolean useWorkingDirectory = false;
16
17 /**
18 * Get the Jar path
19 *
20 * @return Path
21 */
22 public static File getInstallerPath() {
23 String jarPath = Paths.class.getProtectionDomain().getCodeSource()
24 .getLocation().getPath();
25 jarPath = jarPath.replaceAll("\\+", "%2B");
26 String decodedPath = null;
27 try {
28 decodedPath = URLDecoder.decode(jarPath, "UTF-8");
29 } catch (UnsupportedEncodingException e) {
30 e.printStackTrace();
31 }
32 return new File(decodedPath).getParentFile();
33 }
34
35 /**
36 * @return Proxy settings filename of AEI
37 */
38 public static File getProxySettingsFilename() {
39 return new File(getPrefsPath(), "AEI-ProxySettings.xml");
40 }
41
42 /**
43 * Get the preferences path
44 *
45 * @return Path
46 */
47 public static File getPrefsPath() {
48 if (useWorkingDirectory) {
49 String wd = System.getProperty("user.dir");
50 return new File(wd);
51 } else
52 return getInstallerPath();
53 }
54
55 /**
56 * Get the path to store downloaded files
57 *
58 * @return Download path
59 */
60 public static File getDownloadPath() {
61 return new File(getTempPath(), "downloads");
62 }
63
64 /**
65 * Get the systems temp-path
66 *
67 * @return Path
68 */
69 public static File getTempPath() {
70 return new File(System.getProperty("java.io.tmpdir"), "oni_aei");
71 }
72
73}
Note: See TracBrowser for help on using the repository browser.