[596] | 1 | package net.oni2.aeinstaller.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 = Settings.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 path to store mods
|
---|
| 49 | *
|
---|
| 50 | * @return Data path
|
---|
| 51 | */
|
---|
| 52 | public static File getModsPath() {
|
---|
| 53 | return new File(getInstallerPath(), "mods");
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | /**
|
---|
| 57 | * Get the path where vanilla .oni-files are stored
|
---|
| 58 | *
|
---|
| 59 | * @return Vanilla .oni's path
|
---|
| 60 | */
|
---|
| 61 | public static File getVanillaOnisPath() {
|
---|
| 62 | return new File(getInstallerPath(), "vanilla");
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | /**
|
---|
| 66 | * Get the base path of Oni
|
---|
| 67 | *
|
---|
| 68 | * @return Vanilla Oni path
|
---|
| 69 | */
|
---|
| 70 | public static File getOniBasePath() {
|
---|
| 71 | return getInstallerPath().getParentFile().getParentFile();
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | /**
|
---|
| 75 | * Get the base path of the Edition
|
---|
| 76 | *
|
---|
| 77 | * @return Edition path
|
---|
| 78 | */
|
---|
| 79 | public static File getEditionBasePath() {
|
---|
| 80 | return getInstallerPath().getParentFile();
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | /**
|
---|
| 84 | * Get the path where the vanilla Oni GDF is located
|
---|
| 85 | *
|
---|
| 86 | * @return Vanilla Oni GDF
|
---|
| 87 | */
|
---|
| 88 | public static File getVanillaGDF() {
|
---|
| 89 | return new File(getOniBasePath(), "GameDataFolder");
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /**
|
---|
| 93 | * Get the path where the Edition GDF is located
|
---|
| 94 | *
|
---|
| 95 | * @return Edition GDF
|
---|
| 96 | */
|
---|
| 97 | public static File getEditionGDF() {
|
---|
| 98 | return new File(getEditionBasePath(), "GameDataFolder");
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /**
|
---|
| 102 | * Get the systems temp-path
|
---|
| 103 | *
|
---|
| 104 | * @return Path
|
---|
| 105 | */
|
---|
| 106 | public static File getTempPath() {
|
---|
| 107 | return new File(System.getProperty("java.io.tmpdir"), "oni_aei");
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | }
|
---|