Allow directory creation on exposed volumes
This commit is contained in:
parent
5474d6eea5
commit
f4e47c1827
@ -236,14 +236,21 @@ class VolumeProvider: DocumentsProvider() {
|
|||||||
): String? {
|
): String? {
|
||||||
if (!usfExpose || !usfSafWrite) return null
|
if (!usfExpose || !usfSafWrite) return null
|
||||||
val document = parseDocumentId(parentDocumentId) ?: return null
|
val document = parseDocumentId(parentDocumentId) ?: return null
|
||||||
val newFile = PathUtils.pathJoin(document.path, displayName)
|
val path = PathUtils.pathJoin(document.path, displayName)
|
||||||
val f = document.encryptedVolume.openFileWriteMode(newFile)
|
var success = false
|
||||||
return if (f == -1L) {
|
if (mimeType == DocumentsContract.Document.MIME_TYPE_DIR) {
|
||||||
Log.e(TAG, "Failed to create file: $document")
|
success = document.encryptedVolume.mkdir(path)
|
||||||
null
|
|
||||||
} else {
|
} else {
|
||||||
|
val f = document.encryptedVolume.openFileWriteMode(path)
|
||||||
|
if (f != -1L) {
|
||||||
document.encryptedVolume.closeFile(f)
|
document.encryptedVolume.closeFile(f)
|
||||||
document.rootId+newFile
|
success = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return if (success) {
|
||||||
|
document.rootId+path
|
||||||
|
} else {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user