|
|
@ -7,7 +7,7 @@ import android.provider.DocumentsContract |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("unused") |
|
|
|
|
|
|
|
object DocumentUtils { |
|
|
|
object DocumentUtils { |
|
|
|
|
|
|
|
|
|
|
|
fun exists(root: DocumentFile, fileName: String, vararg subDirs: String): Boolean { |
|
|
|
fun exists(root: DocumentFile, fileName: String, vararg subDirs: String): Boolean { |
|
|
@ -139,3 +139,23 @@ data class DocItem( |
|
|
|
DocumentsContract.Document.MIME_TYPE_DIR == attr |
|
|
|
DocumentsContract.Document.MIME_TYPE_DIR == attr |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
|
|
|
fun DocumentFile.writeText(context: Context, data: String) { |
|
|
|
|
|
|
|
DocumentUtils.writeText(context, data, this.uri) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
|
|
|
fun DocumentFile.writeBytes(context: Context, data: ByteArray) { |
|
|
|
|
|
|
|
DocumentUtils.writeBytes(context, data, this.uri) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
|
|
|
fun DocumentFile.readText(context: Context): String? { |
|
|
|
|
|
|
|
return DocumentUtils.readText(context, this.uri) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
|
|
|
fun DocumentFile.readBytes(context: Context): ByteArray? { |
|
|
|
|
|
|
|
return DocumentUtils.readBytes(context, this.uri) |
|
|
|
|
|
|
|
} |
|
|
|