From bcb388e95d17a152b4eac5dcd0971247bf85c016 Mon Sep 17 00:00:00 2001 From: Jackson Coxson Date: Tue, 20 May 2025 11:59:56 -0600 Subject: [PATCH] Add dir_path to crashreport ls --- idevice/src/services/crashreportcopymobile.rs | 8 ++++++-- tools/src/crash_logs.rs | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/idevice/src/services/crashreportcopymobile.rs b/idevice/src/services/crashreportcopymobile.rs index 329b41a..bcd4cd2 100644 --- a/idevice/src/services/crashreportcopymobile.rs +++ b/idevice/src/services/crashreportcopymobile.rs @@ -79,13 +79,17 @@ impl CrashReportCopyMobileClient { /// Lists crash report files in the root of the crash logs directory. /// + /// # Arguments + /// * `dir_path` - The directory to pull logs from. Default is / + /// /// # Returns /// A list of filenames. /// /// # Errors /// Returns `IdeviceError` if listing the directory fails. - pub async fn ls(&mut self) -> Result, IdeviceError> { - let mut res = self.afc_client.list_dir("/").await?; + pub async fn ls(&mut self, dir_path: Option<&str>) -> Result, IdeviceError> { + let path = dir_path.unwrap_or("/"); + let mut res = self.afc_client.list_dir(path).await?; if res.len() > 2 { if &res[0] == "." { res.swap_remove(0); diff --git a/tools/src/crash_logs.rs b/tools/src/crash_logs.rs index 8c545bc..cda1535 100644 --- a/tools/src/crash_logs.rs +++ b/tools/src/crash_logs.rs @@ -43,7 +43,8 @@ async fn main() { Command::new("pull") .about("Pulls a log") .arg(Arg::new("path").required(true).index(1)) - .arg(Arg::new("save").required(true).index(2)), + .arg(Arg::new("save").required(true).index(2)) + .arg(Arg::new("dir").required(false).index(3)), ) .get_matches(); @@ -68,8 +69,12 @@ async fn main() { .await .expect("Unable to connect to misagent"); - if let Some(_matches) = matches.subcommand_matches("list") { - let res = crash_client.ls().await.expect("Failed to read dir"); + if let Some(matches) = matches.subcommand_matches("list") { + let dir_path: Option<&String> = matches.get_one("dir"); + let res = crash_client + .ls(dir_path.map(|x| x.as_str())) + .await + .expect("Failed to read dir"); println!("{res:#?}"); } else if matches.subcommand_matches("flush").is_some() { flush_reports(&*provider).await.expect("Failed to flush");