properly determine if the given root item is a file or folder
This commit is contained in:
parent
8f336838f5
commit
20183d448d
|
@ -32,10 +32,14 @@ class RootHelpers(val activity: Activity) {
|
||||||
val hiddenArgument = if (activity.config.shouldShowHidden) "-A " else ""
|
val hiddenArgument = if (activity.config.shouldShowHidden) "-A " else ""
|
||||||
val cmd = "ls $hiddenArgument$path"
|
val cmd = "ls $hiddenArgument$path"
|
||||||
|
|
||||||
|
getFullLines(path) {
|
||||||
|
val fullLines = it
|
||||||
|
|
||||||
val command = object : Command(0, cmd) {
|
val command = object : Command(0, cmd) {
|
||||||
override fun commandOutput(id: Int, line: String) {
|
override fun commandOutput(id: Int, line: String) {
|
||||||
val file = File(path, line)
|
val file = File(path, line)
|
||||||
val isDirectory = file.isDirectory
|
val fullLine = fullLines.firstOrNull { it.endsWith(" $line") }
|
||||||
|
val isDirectory = fullLine?.startsWith('d') ?: file.isDirectory
|
||||||
val fileDirItem = FileDirItem(file.absolutePath, line, isDirectory, 0, 0)
|
val fileDirItem = FileDirItem(file.absolutePath, line, isDirectory, 0, 0)
|
||||||
files.add(fileDirItem)
|
files.add(fileDirItem)
|
||||||
super.commandOutput(id, line)
|
super.commandOutput(id, line)
|
||||||
|
@ -54,6 +58,27 @@ class RootHelpers(val activity: Activity) {
|
||||||
|
|
||||||
runCommand(command)
|
runCommand(command)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getFullLines(path: String, callback: (ArrayList<String>) -> Unit) {
|
||||||
|
val fullLines = ArrayList<String>()
|
||||||
|
val hiddenArgument = if (activity.config.shouldShowHidden) "-Al " else "-l "
|
||||||
|
val cmd = "ls $hiddenArgument$path"
|
||||||
|
|
||||||
|
val command = object : Command(0, cmd) {
|
||||||
|
override fun commandOutput(id: Int, line: String) {
|
||||||
|
fullLines.add(line)
|
||||||
|
super.commandOutput(id, line)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun commandCompleted(id: Int, exitcode: Int) {
|
||||||
|
callback(fullLines)
|
||||||
|
super.commandCompleted(id, exitcode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runCommand(command)
|
||||||
|
}
|
||||||
|
|
||||||
private fun getChildrenCount(files: ArrayList<FileDirItem>, path: String, callback: (originalPath: String, fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
private fun getChildrenCount(files: ArrayList<FileDirItem>, path: String, callback: (originalPath: String, fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
||||||
val hiddenArgument = if (activity.config.shouldShowHidden) "-A " else ""
|
val hiddenArgument = if (activity.config.shouldShowHidden) "-A " else ""
|
||||||
|
|
Loading…
Reference in New Issue