mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 09:58:08 +00:00
fix: fix logics in newFileChannel()
This commit is contained in:
parent
89454fcba9
commit
ae49aa6456
@ -131,6 +131,9 @@ class SafFileSystemProvider(
|
|||||||
if (options.contains(StandardOpenOption.WRITE)) {
|
if (options.contains(StandardOpenOption.WRITE)) {
|
||||||
throw IllegalArgumentException("Cannot open a file for both reading and writing")
|
throw IllegalArgumentException("Cannot open a file for both reading and writing")
|
||||||
}
|
}
|
||||||
|
if (options.contains(StandardOpenOption.CREATE_NEW) || options.contains(StandardOpenOption.CREATE)) {
|
||||||
|
createFile(path, options.contains(StandardOpenOption.CREATE_NEW))
|
||||||
|
}
|
||||||
val docFile = path.getDocumentFile(context)!!
|
val docFile = path.getDocumentFile(context)!!
|
||||||
return ParcelFileDescriptor.AutoCloseInputStream(
|
return ParcelFileDescriptor.AutoCloseInputStream(
|
||||||
context.contentResolver.openFileDescriptor(docFile.uri, "r")!!
|
context.contentResolver.openFileDescriptor(docFile.uri, "r")!!
|
||||||
@ -138,11 +141,11 @@ class SafFileSystemProvider(
|
|||||||
}
|
}
|
||||||
// WRITE
|
// WRITE
|
||||||
options.contains(StandardOpenOption.WRITE) -> {
|
options.contains(StandardOpenOption.WRITE) -> {
|
||||||
val docFile =
|
|
||||||
path.getDocumentFile(context) ?: throw IOException("Failed to create $path")
|
|
||||||
if (options.contains(StandardOpenOption.CREATE_NEW) || options.contains(StandardOpenOption.CREATE)) {
|
if (options.contains(StandardOpenOption.CREATE_NEW) || options.contains(StandardOpenOption.CREATE)) {
|
||||||
createFile(path, options.contains(StandardOpenOption.CREATE_NEW))
|
createFile(path, options.contains(StandardOpenOption.CREATE_NEW))
|
||||||
}
|
}
|
||||||
|
val docFile =
|
||||||
|
path.getDocumentFile(context) ?: throw IOException("Failed to create $path")
|
||||||
check(docFile.exists())
|
check(docFile.exists())
|
||||||
val mode = when {
|
val mode = when {
|
||||||
options.contains(StandardOpenOption.APPEND) -> "wa"
|
options.contains(StandardOpenOption.APPEND) -> "wa"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user