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

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

AEI2.08, AEIUpdater:

File size: 1.4 KB
RevLine 
[734]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 /**
[777]13 * Use the wd instead of the jar path
14 */
15 public static boolean useWorkingDirectory = false;
16
17 /**
[734]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 String decodedPath = null;
26 try {
27 decodedPath = URLDecoder.decode(jarPath, "UTF-8");
28 } catch (UnsupportedEncodingException e) {
29 e.printStackTrace();
30 }
31 return new File(decodedPath).getParentFile();
32 }
33
34 /**
[852]35 * @return Proxy settings filename of AEI
36 */
37 public static File getProxySettingsFilename() {
38 return new File(getPrefsPath(), "AEI-ProxySettings.xml");
39 }
40
41 /**
[734]42 * Get the preferences path
43 *
44 * @return Path
45 */
46 public static File getPrefsPath() {
[777]47 if (useWorkingDirectory) {
48 String wd = System.getProperty("user.dir");
49 return new File(wd);
50 } else
51 return getInstallerPath();
[734]52 }
53
54 /**
55 * Get the path to store downloaded files
56 *
57 * @return Download path
58 */
59 public static File getDownloadPath() {
60 return new File(getTempPath(), "downloads");
61 }
62
63 /**
64 * Get the systems temp-path
65 *
66 * @return Path
67 */
68 public static File getTempPath() {
69 return new File(System.getProperty("java.io.tmpdir"), "oni_aei");
70 }
71
72}
Note: See TracBrowser for help on using the repository browser.