Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8535500 authored by tibbi's avatar tibbi
Browse files

create a new folder if needed, at getting an SD card file output stream

parent 913a3439
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '4.5.6'
        propVersionName = '4.5.10'
        kotlin_version = '1.2.51'
        support_libs = '27.1.1'
    }
+10 −1
Original line number Diff line number Diff line
@@ -671,7 +671,16 @@ fun BaseSimpleActivity.getFileOutputStreamSync(path: String, mimeType: String, p
    val targetFile = File(path)

    return if (needsStupidWritePermissions(path)) {
        val documentFile = parentDocumentFile ?: getDocumentFile(path.getParentPath())
        var documentFile = parentDocumentFile
        if (documentFile == null) {
            if (targetFile.parentFile.exists()) {
                documentFile = getDocumentFile(targetFile.parentFile.absolutePath)
            } else {
                documentFile = getDocumentFile(targetFile.parentFile.parent)
                documentFile = documentFile!!.createDirectory(targetFile.parentFile.name)
            }
        }

        if (documentFile == null) {
            val error = String.format(getString(R.string.could_not_create_file), targetFile.parent)
            showErrorToast(error)