check if the rooted device has a Hard links column at LS command
This commit is contained in:
parent
f7156ace2b
commit
b8c1e9bdfb
3 changed files with 10 additions and 5 deletions
|
@ -75,4 +75,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var enableRootAccess: Boolean
|
||||
get() = prefs.getBoolean(ENABLE_ROOT_ACCESS, false)
|
||||
set(enableRootAccess) = prefs.edit().putBoolean(ENABLE_ROOT_ACCESS, enableRootAccess).apply()
|
||||
|
||||
var lsHasHardLinksColumn: Boolean
|
||||
get() = prefs.getBoolean(LS_HAS_HARD_LINKS_COLUMN, false)
|
||||
set(lsHasHardLinksColumn) = prefs.edit().putBoolean(LS_HAS_HARD_LINKS_COLUMN, lsHasHardLinksColumn).apply()
|
||||
}
|
||||
|
|
|
@ -12,3 +12,4 @@ val SORT_FOLDER_PREFIX = "sort_folder_"
|
|||
val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
|
||||
val IS_ROOT_AVAILABLE = "is_root_available"
|
||||
val ENABLE_ROOT_ACCESS = "enable_root_access"
|
||||
val LS_HAS_HARD_LINKS_COLUMN = "ls_has_hard_links_column"
|
||||
|
|
|
@ -12,11 +12,10 @@ import java.util.*
|
|||
|
||||
class RootHelpers {
|
||||
fun askRootIFNeeded(activity: SimpleActivity, callback: (success: Boolean) -> Unit) {
|
||||
val SIMPLE_MOBILE_TOOLS = "simple mobile tools"
|
||||
val command = object : Command(0, "echo $SIMPLE_MOBILE_TOOLS") {
|
||||
val command = object : Command(0, "ls -la | awk '{ print $2 }'") {
|
||||
override fun commandOutput(id: Int, line: String) {
|
||||
if (line == SIMPLE_MOBILE_TOOLS)
|
||||
callback(true)
|
||||
activity.config.lsHasHardLinksColumn = line.areDigitsOnly()
|
||||
callback(true)
|
||||
super.commandOutput(id, line)
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +31,9 @@ class RootHelpers {
|
|||
fun getFiles(activity: SimpleActivity, path: String, callback: (fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
||||
val files = ArrayList<FileDirItem>()
|
||||
val showHidden = activity.config.shouldShowHidden
|
||||
val sizeColumnIndex = if (activity.config.lsHasHardLinksColumn) 5 else 4
|
||||
|
||||
val cmd = "ls -la $path | awk '{ system(\"echo \"\$1\" \"\$4\" `find $path/\"\$NF\" -mindepth 1 -maxdepth 1 | wc -l` \"\$NF\" \")}'"
|
||||
val cmd = "ls -la $path | awk '{ system(\"echo \"\$1\" \"\$$sizeColumnIndex\" `find ${path.trimEnd('/')}/\"\$NF\" -mindepth 1 -maxdepth 1 | wc -l` \"\$NF\" \")}'"
|
||||
val command = object : Command(0, cmd) {
|
||||
override fun commandOutput(id: Int, line: String) {
|
||||
val parts = line.split(" ")
|
||||
|
|
Loading…
Reference in a new issue