arwen/cli/
delete.rs

1use std::path::PathBuf;
2
3use clap::Parser;
4
5use crate::macho::{MachoContainer, MachoError};
6
7/// Remove a run path
8#[derive(Parser, Debug)]
9pub struct Args {
10    /// Rpath to remove
11    pub rpath_to_remove: String,
12
13    /// Path to the file to change
14    pub path_to_binary: PathBuf,
15}
16
17pub fn execute(args: Args) -> Result<(), MachoError> {
18    let bytes_of_file = std::fs::read(&args.path_to_binary).unwrap();
19
20    let mut macho = MachoContainer::parse(&bytes_of_file)?;
21
22    macho.remove_rpath(&args.rpath_to_remove)?;
23
24    std::fs::write(args.path_to_binary, macho.data).unwrap();
25
26    Ok(())
27}