diff options
author | Pacien TRAN-GIRARD | 2017-07-03 17:59:30 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2017-07-03 17:59:30 +0200 |
commit | ab577b06a6eaa9b8dd950b79b658ed8c08eef1c9 (patch) | |
tree | bc815e8d98a536522ce9c2d88e14bbd3ee8b7bec /app/src/main/java/org/pacien/tincapp/context | |
parent | 328ad552b0b508e08072ebcd9409f6214c748a0d (diff) | |
download | tincapp-ab577b06a6eaa9b8dd950b79b658ed8c08eef1c9.tar.gz |
Drop useless support for configuration in internal storage
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/context')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/context/AppPaths.kt | 26 |
1 files changed, 6 insertions, 20 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 58c6de2..078a81d 100644 --- a/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt +++ b/app/src/main/java/org/pacien/tincapp/context/AppPaths.kt | |||
@@ -1,7 +1,6 @@ | |||
1 | package org.pacien.tincapp.context | 1 | package org.pacien.tincapp.context |
2 | 2 | ||
3 | import java.io.File | 3 | import java.io.File |
4 | import java.io.Serializable | ||
5 | 4 | ||
6 | /** | 5 | /** |
7 | * @author pacien | 6 | * @author pacien |
@@ -10,9 +9,6 @@ import java.io.Serializable | |||
10 | */ | 9 | */ |
11 | object AppPaths { | 10 | object AppPaths { |
12 | 11 | ||
13 | enum class Storage { INTERNAL, EXTERNAL } | ||
14 | data class NetConf(val storage: Storage, val netName: String) : Serializable | ||
15 | |||
16 | private val TINCD_BIN = "libtincd.so" | 12 | private val TINCD_BIN = "libtincd.so" |
17 | private val TINC_BIN = "libtinc.so" | 13 | private val TINC_BIN = "libtinc.so" |
18 | 14 | ||
@@ -21,24 +17,14 @@ object AppPaths { | |||
21 | 17 | ||
22 | private val NET_CONF_FILE = "network.conf" | 18 | private val NET_CONF_FILE = "network.conf" |
23 | 19 | ||
24 | fun filesDir(storage: Storage): File = when (storage) { | 20 | fun cacheDir() = App.getContext().externalCacheDir!! |
25 | Storage.INTERNAL -> App.getContext().filesDir | 21 | fun confDir() = App.getContext().getExternalFilesDir(null)!! |
26 | Storage.EXTERNAL -> App.getContext().getExternalFilesDir(null) | ||
27 | } | ||
28 | |||
29 | fun cacheDir(storage: Storage): File = when (storage) { | ||
30 | Storage.INTERNAL -> App.getContext().cacheDir | ||
31 | Storage.EXTERNAL -> App.getContext().externalCacheDir | ||
32 | } | ||
33 | |||
34 | fun binDir() = File(App.getContext().applicationInfo.nativeLibraryDir) | 22 | fun binDir() = File(App.getContext().applicationInfo.nativeLibraryDir) |
35 | 23 | ||
36 | fun confDir(storage: Storage) = filesDir(storage) | 24 | fun confDir(netName: String) = File(confDir(), netName) |
37 | fun confDir(netConf: NetConf) = File(confDir(netConf.storage), netConf.netName) | 25 | fun netConfFile(netName: String) = File(confDir(netName), NET_CONF_FILE) |
38 | 26 | fun logFile(netName: String) = File(cacheDir(), String.format(LOGFILE_FORMAT, netName)) | |
39 | fun netConfFile(netConf: NetConf) = File(confDir(netConf), NET_CONF_FILE) | 27 | fun pidFile(netName: String) = File(App.getContext().cacheDir, String.format(PIDFILE_FORMAT, netName)) |
40 | fun logFile(netConf: NetConf) = File(cacheDir(netConf.storage), String.format(LOGFILE_FORMAT, netConf.netName)) | ||
41 | fun pidFile(netConf: NetConf) = File(cacheDir(Storage.INTERNAL), String.format(PIDFILE_FORMAT, netConf.netName)) | ||
42 | 28 | ||
43 | fun tincd() = File(binDir(), TINCD_BIN) | 29 | fun tincd() = File(binDir(), TINCD_BIN) |
44 | fun tinc() = File(binDir(), TINC_BIN) | 30 | fun tinc() = File(binDir(), TINC_BIN) |