1 |
package net.oni2.aeinstaller.updater.backend; |
2 |
|
3 |
import java.io.File; |
4 |
import java.io.UnsupportedEncodingException; |
5 |
import java.net.URLDecoder; |
6 |
|
7 |
/** |
8 |
* @author Christian Illy |
9 |
*/ |
10 |
public class Paths { |
11 |
|
12 |
/** |
13 |
* Get the Jar path |
14 |
* |
15 |
* @return Path |
16 |
*/ |
17 |
public static File getInstallerPath() { |
18 |
String jarPath = Paths.class.getProtectionDomain().getCodeSource() |
19 |
.getLocation().getPath(); |
20 |
String decodedPath = null; |
21 |
try { |
22 |
decodedPath = URLDecoder.decode(jarPath, "UTF-8"); |
23 |
} catch (UnsupportedEncodingException e) { |
24 |
e.printStackTrace(); |
25 |
} |
26 |
return new File(decodedPath).getParentFile(); |
27 |
} |
28 |
|
29 |
/** |
30 |
* Get the preferences path |
31 |
* |
32 |
* @return Path |
33 |
*/ |
34 |
public static File getPrefsPath() { |
35 |
return getInstallerPath(); |
36 |
} |
37 |
|
38 |
/** |
39 |
* Get the path to store downloaded files |
40 |
* |
41 |
* @return Download path |
42 |
*/ |
43 |
public static File getDownloadPath() { |
44 |
return new File(getTempPath(), "downloads"); |
45 |
} |
46 |
|
47 |
/** |
48 |
* Get the systems temp-path |
49 |
* |
50 |
* @return Path |
51 |
*/ |
52 |
public static File getTempPath() { |
53 |
return new File(System.getProperty("java.io.tmpdir"), "oni_aei"); |
54 |
} |
55 |
|
56 |
} |