diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt index a68615f1..a2ce9b3e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt @@ -66,6 +66,15 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca success(alertDialog) } } + else -> { + RootHelpers().createFileFolder(activity, path, false) { + if (it) { + success(alertDialog) + } else { + callback(false) + } + } + } } } @@ -91,7 +100,7 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca } } else -> { - RootHelpers().createFile(activity, path) { + RootHelpers().createFileFolder(activity, path, true) { if (it) { success(alertDialog) } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt index d9777127..888898e5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt @@ -130,11 +130,12 @@ class RootHelpers { } } - fun createFile(activity: SimpleActivity, path: String, callback: (success: Boolean) -> Unit) { + fun createFileFolder(activity: SimpleActivity, path: String, isFile: Boolean, callback: (success: Boolean) -> Unit) { tryMountAsRW(activity, path) { val mountPoint = it val targetPath = path.trim('/') - val cmd = "touch \"/$targetPath\"" + val mainCommand = if (isFile) "touch" else "mkdir" + val cmd = "$mainCommand \"/$targetPath\"" val command = object : Command(0, cmd) { override fun commandCompleted(id: Int, exitcode: Int) { callback(exitcode == 0) @@ -179,7 +180,7 @@ class RootHelpers { } } - if (mountPoint != "" && types != null) { + if (mountPoint.isNotEmpty() && types != null) { if (types.contains("rw")) { callback(null) } else if (types.contains("ro")) {