aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt
diff options
context:
space:
mode:
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.kt12
1 files changed, 7 insertions, 5 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 0b85565..1efb7cf 100644
--- a/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt
+++ b/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt
@@ -43,13 +43,15 @@ object AppPaths {
43 private const val NET_DEFAULT_ED25519_PRIVATE_KEY_FILE = "ed25519_key.priv" 43 private const val NET_DEFAULT_ED25519_PRIVATE_KEY_FILE = "ed25519_key.priv"
44 private const val NET_DEFAULT_RSA_PRIVATE_KEY_FILE = "rsa_key.priv" 44 private const val NET_DEFAULT_RSA_PRIVATE_KEY_FILE = "rsa_key.priv"
45 45
46 private val context by lazy { App.getContext() }
47
46 fun storageAvailable() = 48 fun storageAvailable() =
47 Environment.getExternalStorageState().let { it == Environment.MEDIA_MOUNTED && it != Environment.MEDIA_MOUNTED_READ_ONLY } 49 Environment.getExternalStorageState().let { it == Environment.MEDIA_MOUNTED && it != Environment.MEDIA_MOUNTED_READ_ONLY }
48 50
49 private fun internalCacheDir() = App.getContext().cacheDir!! 51 private fun internalCacheDir() = context.cacheDir!!
50 fun cacheDir() = App.getContext().externalCacheDir!! 52 fun cacheDir() = context.externalCacheDir!!
51 fun confDir() = App.getContext().getExternalFilesDir(null)!! 53 fun confDir() = context.getExternalFilesDir(null)!!
52 private fun binDir() = File(App.getContext().applicationInfo.nativeLibraryDir) 54 private fun binDir() = File(context.applicationInfo.nativeLibraryDir)
53 55
54 fun confDir(netName: String) = File(confDir(), netName) 56 fun confDir(netName: String) = File(confDir(), netName)
55 fun hostsDir(netName: String) = File(confDir(netName), NET_HOSTS_DIR) 57 fun hostsDir(netName: String) = File(confDir(netName), NET_HOSTS_DIR)
@@ -57,7 +59,7 @@ object AppPaths {
57 fun tincConfFile(netName: String) = File(confDir(netName), NET_TINC_CONF_FILE) 59 fun tincConfFile(netName: String) = File(confDir(netName), NET_TINC_CONF_FILE)
58 fun invitationFile(netName: String) = File(confDir(netName), NET_INVITATION_FILE) 60 fun invitationFile(netName: String) = File(confDir(netName), NET_INVITATION_FILE)
59 fun logFile(netName: String) = File(cacheDir(), String.format(LOGFILE_FORMAT, netName)) 61 fun logFile(netName: String) = File(cacheDir(), String.format(LOGFILE_FORMAT, netName))
60 fun pidFile(netName: String) = File(App.getContext().cacheDir, String.format(PIDFILE_FORMAT, netName)) 62 fun pidFile(netName: String) = File(context.cacheDir, String.format(PIDFILE_FORMAT, netName))
61 fun appLogFile() = File(cacheDir(), APPLOG_FILE) 63 fun appLogFile() = File(cacheDir(), APPLOG_FILE)
62 fun crashFlagFile() = File(internalCacheDir(), CRASHFLAG_FILE) 64 fun crashFlagFile() = File(internalCacheDir(), CRASHFLAG_FILE)
63 65