diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-26 23:21:54 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-26 23:21:54 -0600 |
commit | 37949ba1ec44bcc9051075cf553cd92df203dff3 (patch) | |
tree | 6045d4ed83e3ab5b39de7c895c35a3dd0dd9202c /ui/src/main/java/com/wireguard/android/configStore | |
parent | util: Start converting to Kotlin (diff) | |
download | wireguard-android-37949ba1ec44bcc9051075cf553cd92df203dff3.tar.xz wireguard-android-37949ba1ec44bcc9051075cf553cd92df203dff3.zip |
TunnelManager: convert to kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/configStore')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.kt | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.kt b/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.kt index c8d47b40..bda91ae3 100644 --- a/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.kt +++ b/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.kt @@ -24,8 +24,9 @@ class FileConfigStore(private val context: Context) : ConfigStore { override fun create(name: String, config: Config): Config { Log.d(TAG, "Creating configuration for tunnel $name") val file = fileFor(name) - if (!file.createNewFile()) throw IOException(context.getString(R.string.config_file_exists_error, file.name)) - FileOutputStream(file, false).use { stream -> stream.write(config.toWgQuickString().toByteArray(StandardCharsets.UTF_8)) } + if (!file.createNewFile()) + throw IOException(context.getString(R.string.config_file_exists_error, file.name)) + FileOutputStream(file, false).use { it.write(config.toWgQuickString().toByteArray(StandardCharsets.UTF_8)) } return config } @@ -33,7 +34,8 @@ class FileConfigStore(private val context: Context) : ConfigStore { override fun delete(name: String) { Log.d(TAG, "Deleting configuration for tunnel $name") val file = fileFor(name) - if (!file.delete()) throw IOException(context.getString(R.string.config_delete_error, file.name)) + if (!file.delete()) + throw IOException(context.getString(R.string.config_delete_error, file.name)) } override fun enumerate(): Set<String> { @@ -68,7 +70,8 @@ class FileConfigStore(private val context: Context) : ConfigStore { override fun save(name: String, config: Config): Config { Log.d(TAG, "Saving configuration for tunnel $name") val file = fileFor(name) - if (!file.isFile) throw FileNotFoundException(context.getString(R.string.config_not_found_error, file.name)) + if (!file.isFile) + throw FileNotFoundException(context.getString(R.string.config_not_found_error, file.name)) FileOutputStream(file, false).use { stream -> stream.write(config.toWgQuickString().toByteArray(StandardCharsets.UTF_8)) } return config } |