mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
add handling for root file copy
This commit is contained in:
@ -255,4 +255,23 @@ class RootHelpers(val activity: Activity) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun copyFiles(fileDirItems: ArrayList<FileDirItem>, destination: String, successes: Int = 0, callback: (Int) -> Unit) {
|
||||
val fileDirItem = fileDirItems.first()
|
||||
val mainCommand = if (fileDirItem.isDirectory) "cp -R" else "cp"
|
||||
val cmd = "$mainCommand \"${fileDirItem.path}\" \"$destination\""
|
||||
val command = object : Command(0, cmd) {
|
||||
override fun commandCompleted(id: Int, exitcode: Int) {
|
||||
val newSuccesses = successes + (if (exitcode == 0) 1 else 0)
|
||||
if (fileDirItems.size == 1) {
|
||||
callback(newSuccesses)
|
||||
} else {
|
||||
fileDirItems.removeAt(0)
|
||||
copyFiles(fileDirItems, destination, newSuccesses, callback)
|
||||
}
|
||||
super.commandCompleted(id, exitcode)
|
||||
}
|
||||
}
|
||||
runCommand(command)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user