diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2023-12-17 12:16:35 +0530 |
|---|---|---|
| committer | Harsh Shandilya <me@msfjarvis.dev> | 2023-12-17 12:16:35 +0530 |
| commit | 7c3410f390c7d12315e7c3e829c1714435361fe8 (patch) | |
| tree | 18ec78cb053107ea79ceb5f3e46ed0da38565649 /openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/ParcelFileDescriptorUtil.kt | |
| parent | 97bc1e0ce52fc8411b252ae912bac40d29feee64 (diff) | |
| download | HardenedPass-7c3410f390c7d12315e7c3e829c1714435361fe8.tar.gz HardenedPass-7c3410f390c7d12315e7c3e829c1714435361fe8.zip | |
chore: remove obsolete openpgp-ktx code
Diffstat (limited to 'openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/ParcelFileDescriptorUtil.kt')
| -rw-r--r-- | openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/ParcelFileDescriptorUtil.kt | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/ParcelFileDescriptorUtil.kt b/openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/ParcelFileDescriptorUtil.kt deleted file mode 100644 index 1229b95c..00000000 --- a/openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/ParcelFileDescriptorUtil.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ -@file:Suppress("BlockingMethodInNonBlockingContext") - -package me.msfjarvis.openpgpktx.util - -import android.os.ParcelFileDescriptor -import android.os.ParcelFileDescriptor.AutoCloseInputStream -import android.os.ParcelFileDescriptor.AutoCloseOutputStream -import android.util.Log -import java.io.IOException -import java.io.InputStream -import java.io.OutputStream -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext - -internal object ParcelFileDescriptorUtil { - - private const val TAG = "PFDUtils" - - internal suspend fun pipeFrom(inputStream: InputStream): ParcelFileDescriptor { - val pipe = ParcelFileDescriptor.createPipe() - val readSide = pipe[0] - val writeSide = pipe[1] - transferStreams(inputStream, AutoCloseOutputStream(writeSide)) - return readSide - } - - internal suspend fun pipeTo(outputStream: OutputStream, output: ParcelFileDescriptor?) { - transferStreams(AutoCloseInputStream(output), outputStream) - } - - private suspend fun transferStreams(`in`: InputStream, `out`: OutputStream) { - withContext(Dispatchers.IO) { - val buf = ByteArray(4096) - var len: Int - try { - while (`in`.read(buf).also { len = it } > 0) { - out.write(buf, 0, len) - } - } catch (e: IOException) { - Log.e(TAG, "IOException when writing to out", e) - } finally { - try { - `in`.close() - } catch (ignored: IOException) {} - try { - out.close() - } catch (ignored: IOException) {} - } - } - } -} |
