diff options
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/context/AppPaths.kt')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/context/AppPaths.kt | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt b/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt index 673faa7..94780cc 100644 --- a/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt +++ b/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt | |||
@@ -17,8 +17,11 @@ object AppPaths { | |||
17 | private val PIDFILE_FORMAT = "tinc.%s.pid" | 17 | private val PIDFILE_FORMAT = "tinc.%s.pid" |
18 | 18 | ||
19 | private val NET_CONF_FILE = "network.conf" | 19 | private val NET_CONF_FILE = "network.conf" |
20 | private val NET_TINC_CONF_FILE = "tinc.conf" | ||
20 | private val NET_HOSTS_DIR = "hosts" | 21 | private val NET_HOSTS_DIR = "hosts" |
21 | private val NET_INVITATION_FILE = "invitation-data" | 22 | private val NET_INVITATION_FILE = "invitation-data" |
23 | private val NET_DEFAULT_ED25519_PRIVATE_KEY_FILE = "ed25519_key.priv" | ||
24 | private val NET_DEFAULT_RSA_PRIVATE_KEY_FILE = "rsa_key.priv" | ||
22 | 25 | ||
23 | fun cacheDir() = App.getContext().externalCacheDir!! | 26 | fun cacheDir() = App.getContext().externalCacheDir!! |
24 | fun confDir() = App.getContext().getExternalFilesDir(null)!! | 27 | fun confDir() = App.getContext().getExternalFilesDir(null)!! |
@@ -27,12 +30,16 @@ object AppPaths { | |||
27 | fun confDir(netName: String) = File(confDir(), netName) | 30 | fun confDir(netName: String) = File(confDir(), netName) |
28 | fun hostsDir(netName: String) = File(confDir(netName), NET_HOSTS_DIR) | 31 | fun hostsDir(netName: String) = File(confDir(netName), NET_HOSTS_DIR) |
29 | fun netConfFile(netName: String) = File(confDir(netName), NET_CONF_FILE) | 32 | fun netConfFile(netName: String) = File(confDir(netName), NET_CONF_FILE) |
33 | fun tincConfFile(netName: String) = File(confDir(netName), NET_TINC_CONF_FILE) | ||
30 | fun invitationFile(netName: String) = File(confDir(netName), NET_INVITATION_FILE) | 34 | fun invitationFile(netName: String) = File(confDir(netName), NET_INVITATION_FILE) |
31 | fun logFile(netName: String) = File(cacheDir(), String.format(LOGFILE_FORMAT, netName)) | 35 | fun logFile(netName: String) = File(cacheDir(), String.format(LOGFILE_FORMAT, netName)) |
32 | fun pidFile(netName: String) = File(App.getContext().cacheDir, String.format(PIDFILE_FORMAT, netName)) | 36 | fun pidFile(netName: String) = File(App.getContext().cacheDir, String.format(PIDFILE_FORMAT, netName)) |
33 | 37 | ||
34 | fun existing(f: File) = f.apply { if (!exists()) throw FileNotFoundException(f.absolutePath) } | 38 | fun existing(f: File) = f.apply { if (!exists()) throw FileNotFoundException(f.absolutePath) } |
35 | 39 | ||
40 | fun defaultEd25519PrivateKeyFile(netName: String) = File(confDir(netName), NET_DEFAULT_ED25519_PRIVATE_KEY_FILE) | ||
41 | fun defaultRsaPrivateKeyFile(netName: String) = File(confDir(netName), NET_DEFAULT_RSA_PRIVATE_KEY_FILE) | ||
42 | |||
36 | fun tincd() = File(binDir(), TINCD_BIN) | 43 | fun tincd() = File(binDir(), TINCD_BIN) |
37 | fun tinc() = File(binDir(), TINC_BIN) | 44 | fun tinc() = File(binDir(), TINC_BIN) |
38 | 45 | ||