allow creating root folders too
This commit is contained in:
parent
cdedabddbb
commit
b03db843f2
|
@ -66,6 +66,15 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
||||||
success(alertDialog)
|
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 -> {
|
else -> {
|
||||||
RootHelpers().createFile(activity, path) {
|
RootHelpers().createFileFolder(activity, path, true) {
|
||||||
if (it) {
|
if (it) {
|
||||||
success(alertDialog)
|
success(alertDialog)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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) {
|
tryMountAsRW(activity, path) {
|
||||||
val mountPoint = it
|
val mountPoint = it
|
||||||
val targetPath = path.trim('/')
|
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) {
|
val command = object : Command(0, cmd) {
|
||||||
override fun commandCompleted(id: Int, exitcode: Int) {
|
override fun commandCompleted(id: Int, exitcode: Int) {
|
||||||
callback(exitcode == 0)
|
callback(exitcode == 0)
|
||||||
|
@ -179,7 +180,7 @@ class RootHelpers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mountPoint != "" && types != null) {
|
if (mountPoint.isNotEmpty() && types != null) {
|
||||||
if (types.contains("rw")) {
|
if (types.contains("rw")) {
|
||||||
callback(null)
|
callback(null)
|
||||||
} else if (types.contains("ro")) {
|
} else if (types.contains("ro")) {
|
||||||
|
|
Loading…
Reference in New Issue