mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
check if the rooted device has a Hard links column at LS command
This commit is contained in:
@ -75,4 +75,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var enableRootAccess: Boolean
|
var enableRootAccess: Boolean
|
||||||
get() = prefs.getBoolean(ENABLE_ROOT_ACCESS, false)
|
get() = prefs.getBoolean(ENABLE_ROOT_ACCESS, false)
|
||||||
set(enableRootAccess) = prefs.edit().putBoolean(ENABLE_ROOT_ACCESS, enableRootAccess).apply()
|
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 TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
|
||||||
val IS_ROOT_AVAILABLE = "is_root_available"
|
val IS_ROOT_AVAILABLE = "is_root_available"
|
||||||
val ENABLE_ROOT_ACCESS = "enable_root_access"
|
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 {
|
class RootHelpers {
|
||||||
fun askRootIFNeeded(activity: SimpleActivity, callback: (success: Boolean) -> Unit) {
|
fun askRootIFNeeded(activity: SimpleActivity, callback: (success: Boolean) -> Unit) {
|
||||||
val SIMPLE_MOBILE_TOOLS = "simple mobile tools"
|
val command = object : Command(0, "ls -la | awk '{ print $2 }'") {
|
||||||
val command = object : Command(0, "echo $SIMPLE_MOBILE_TOOLS") {
|
|
||||||
override fun commandOutput(id: Int, line: String) {
|
override fun commandOutput(id: Int, line: String) {
|
||||||
if (line == SIMPLE_MOBILE_TOOLS)
|
activity.config.lsHasHardLinksColumn = line.areDigitsOnly()
|
||||||
callback(true)
|
callback(true)
|
||||||
super.commandOutput(id, line)
|
super.commandOutput(id, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,8 +31,9 @@ class RootHelpers {
|
|||||||
fun getFiles(activity: SimpleActivity, path: String, callback: (fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
fun getFiles(activity: SimpleActivity, path: String, callback: (fileDirItems: ArrayList<FileDirItem>) -> Unit) {
|
||||||
val files = ArrayList<FileDirItem>()
|
val files = ArrayList<FileDirItem>()
|
||||||
val showHidden = activity.config.shouldShowHidden
|
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) {
|
val command = object : Command(0, cmd) {
|
||||||
override fun commandOutput(id: Int, line: String) {
|
override fun commandOutput(id: Int, line: String) {
|
||||||
val parts = line.split(" ")
|
val parts = line.split(" ")
|
||||||
|
Reference in New Issue
Block a user