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 | 24 |
1 files changed, 13 insertions, 11 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 9315060..4b36dfe 100644 --- a/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt +++ b/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt | |||
@@ -10,21 +10,22 @@ import java.io.FileNotFoundException | |||
10 | * @implNote Logs and PID files are stored in the cache directory for easy clean up. | 10 | * @implNote Logs and PID files are stored in the cache directory for easy clean up. |
11 | */ | 11 | */ |
12 | object AppPaths { | 12 | object AppPaths { |
13 | private val TINCD_BIN = "libtincd.so" | 13 | private const val TINCD_BIN = "libtincd.so" |
14 | private val TINC_BIN = "libtinc.so" | 14 | private const val TINC_BIN = "libtinc.so" |
15 | 15 | ||
16 | private val LOGFILE_FORMAT = "tinc.%s.log" | 16 | private const val APPLOG_FILE = "tincapp.log" |
17 | private val PIDFILE_FORMAT = "tinc.%s.pid" | 17 | private const val LOGFILE_FORMAT = "tinc.%s.log" |
18 | private const val PIDFILE_FORMAT = "tinc.%s.pid" | ||
18 | 19 | ||
19 | private val NET_CONF_FILE = "network.conf" | 20 | private const val NET_CONF_FILE = "network.conf" |
20 | private val NET_TINC_CONF_FILE = "tinc.conf" | 21 | private const val NET_TINC_CONF_FILE = "tinc.conf" |
21 | private val NET_HOSTS_DIR = "hosts" | 22 | private const val NET_HOSTS_DIR = "hosts" |
22 | private val NET_INVITATION_FILE = "invitation-data" | 23 | private const val NET_INVITATION_FILE = "invitation-data" |
23 | private val NET_DEFAULT_ED25519_PRIVATE_KEY_FILE = "ed25519_key.priv" | 24 | private const val NET_DEFAULT_ED25519_PRIVATE_KEY_FILE = "ed25519_key.priv" |
24 | private val NET_DEFAULT_RSA_PRIVATE_KEY_FILE = "rsa_key.priv" | 25 | private const val NET_DEFAULT_RSA_PRIVATE_KEY_FILE = "rsa_key.priv" |
25 | 26 | ||
26 | fun storageAvailable() = | 27 | fun storageAvailable() = |
27 | Environment.getExternalStorageState().let { it == Environment.MEDIA_MOUNTED && it != Environment.MEDIA_MOUNTED_READ_ONLY } | 28 | Environment.getExternalStorageState().let { it == Environment.MEDIA_MOUNTED && it != Environment.MEDIA_MOUNTED_READ_ONLY } |
28 | 29 | ||
29 | fun cacheDir() = App.getContext().externalCacheDir | 30 | fun cacheDir() = App.getContext().externalCacheDir |
30 | fun confDir() = App.getContext().getExternalFilesDir(null) | 31 | fun confDir() = App.getContext().getExternalFilesDir(null) |
@@ -37,6 +38,7 @@ object AppPaths { | |||
37 | fun invitationFile(netName: String) = File(confDir(netName), NET_INVITATION_FILE) | 38 | fun invitationFile(netName: String) = File(confDir(netName), NET_INVITATION_FILE) |
38 | fun logFile(netName: String) = File(cacheDir(), String.format(LOGFILE_FORMAT, netName)) | 39 | fun logFile(netName: String) = File(cacheDir(), String.format(LOGFILE_FORMAT, netName)) |
39 | fun pidFile(netName: String) = File(App.getContext().cacheDir, String.format(PIDFILE_FORMAT, netName)) | 40 | fun pidFile(netName: String) = File(App.getContext().cacheDir, String.format(PIDFILE_FORMAT, netName)) |
41 | fun appLogFile() = File(cacheDir(), APPLOG_FILE) | ||
40 | 42 | ||
41 | fun existing(f: File) = f.apply { if (!exists()) throw FileNotFoundException(f.absolutePath) } | 43 | fun existing(f: File) = f.apply { if (!exists()) throw FileNotFoundException(f.absolutePath) } |
42 | 44 | ||