Skip to content

Commit

Permalink
dylibs command extended
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsynth committed Jun 13, 2023
1 parent d9423f5 commit 466924a
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions src/commands/dylibs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ impl Handler for DylibsHandler {
if out_arch {
common::out_single_arch_title(&self.printer, &obj.header(), idx, format.short);
}
self.handle_load_commands(obj.load_commands_iterator(), format);
self.handle_rpath_commands(obj.load_commands_iterator(), format);
self.handle_dylib_commands(obj.load_commands_iterator(), format);
}

Ok(())
Expand All @@ -61,22 +62,50 @@ impl Handler for DylibsHandler {
}

impl DylibsHandler {
fn handle_load_commands(&self, commands: LoadCommandIterator, format: &Format) {
let commands = commands.flat_map(|cmd| match cmd.variant {
fn handle_rpath_commands(&self, commands: LoadCommandIterator, format: &Format) {
let commands: Vec<LcRpath> = commands.flat_map(|cmd| match cmd.variant {
LcVariant::Rpath(rpath) => Some(rpath),
_ => None,
}).collect();

if commands.len() > 0 {
println!("{}", "Relative paths:".cyan());
for (index, cmd) in commands.iter().enumerate() {
if format.show_indices {
self.printer.out_list_item_dash(0, index);
}
self.printer.print_line(common::colored_path_string(cmd.path.to_string()));
}
println!("");
} else {
println!("{}", "No relative paths".dimmed());
}
}

fn handle_dylib_commands(&self, commands: LoadCommandIterator, format: &Format) {
let commands: Vec<LcDylib> = commands.flat_map(|cmd| match cmd.variant {
LcVariant::LoadDylib(dylib) => Some(dylib),
_ => None,
});
for (index, cmd) in commands.enumerate() {
self.handle_dylib_command(cmd, index, format);
}).collect();

if commands.len() > 0 {
println!("{}", "Dynamic libraries:".cyan());
for (index, cmd) in commands.iter().enumerate() {
self.handle_dylib_command(cmd, index, format);
}
println!("");
} else {
println!("{}", "No dynamic libraries".dimmed());
}

}

fn handle_dylib_command(&self, dylib: LcDylib, index: usize, format: &Format) {
fn handle_dylib_command(&self, dylib: &LcDylib, index: usize, format: &Format) {
if format.show_indices {
self.printer.out_list_item_dash(0, index);
}

let name = common::colored_path_string(dylib.name);
let name = common::colored_path_string(dylib.name.to_string());
self.printer.print_string(name);

if !format.short {
Expand Down

0 comments on commit 466924a

Please sign in to comment.