diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/Config.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/Config.kt index 90616901..0cecb0ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/Config.kt @@ -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() } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/Constants.kt index 7c908a1a..3921e77b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/Constants.kt @@ -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" 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 6546c910..5c4bcc1f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt @@ -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) -> Unit) { val files = ArrayList() 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(" ")