Folder scan function
private static string[] lsDir(String dirPath, bool sudo = true) { List<string> item = new List<string>(); try { using (Java.Lang.Process p = sudo ? Java.Lang.Runtime.GetRuntime().Exec(new string[] { "su", "-c", "ls", "-sal", dirPath }) : Java.Lang.Runtime.GetRuntime().Exec(new string[] { "ls", "-lsa", dirPath })) { try { p.Wait(); } catch { } try { p.WaitFor(); } catch { } using (BufferedReader log = new BufferedReader(new InputStreamReader(p.InputStream))) { string line; while ((line = log.ReadLine()) != null) item.Add(line); } } return item.ToArray(); } catch { } return new string[0]; }
now proparsim
string[] dirs = lsDir(item.Data, false); if (dirs.Length == 0) dirs = lsDir(item.Data); Regex regex = new Regex(@"^(?<type>[-|d|l|b|c|p|s]{1})(?<perm>[r|w|x|-]{9}){1}[ ](?<owner>[\S]*)[ ]+(?<group>[\S]*)[ ]+(?<size>\d*)[ ]*(?<dt>[\d]{4}-[\d]{2}-[\d]{2}[ ][\d]{2}:[\d]{2})[ ](?<fn>[\S]+)$", RegexOptions.IgnoreCase); foreach (string i in dirs) { if (match.Groups["type"].Captures.Count != 1) continue; if (match.Groups["perm"].Captures.Count != 1) continue; if (match.Groups["owner"].Captures.Count != 1) continue; if (match.Groups["group"].Captures.Count != 1) continue; if (match.Groups["size"].Captures.Count != 1) continue; //может быть пустым "" if (match.Groups["dt"].Captures.Count != 1) continue; if (match.Groups["fn"].Captures.Count != 1) continue; //Все данные хранятся по Captures //match.Groups[key].Captures[0].Value }
ROOTrights - Dmitry Chistik