[734] | 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 | /**
|
---|
[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 | }
|
---|