Skip to content

Commit

Permalink
Add file mode (permissions) to list-files
Browse files Browse the repository at this point in the history
  • Loading branch information
veselink1 authored and peterwaller-arm committed Aug 20, 2023
1 parent f64509f commit 51edd5c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/bin/elfshaker/list_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,25 @@ pub(crate) fn get_app() -> App<'static, 'static> {
\t%o - file checksum\n\
\t%f - file name\n\
\t%h - human-readable size\n\
\t%b - size in bytes\n",
\t%b - size in bytes\n\
\t%p - permissions",
),
)
}

fn format_file_row(fmt: &str, checksum: &ObjectChecksum, file_name: &OsStr, size: u64) -> String {
fn format_file_row(
fmt: &str,
checksum: &ObjectChecksum,
file_name: &OsStr,
size: u64,
file_mode: u32,
) -> String {
fmt.to_owned()
.replace("%o", &hex::encode(checksum))
.replace("%f", &file_name.to_string_lossy())
.replace("%h", &format_size(size))
.replace("%b", &size.to_string())
.replace("%p", &format!("{:o}", file_mode))
}

fn print_files(
Expand All @@ -80,6 +88,7 @@ fn print_files(
&entry.checksum,
&entry.path,
entry.object_metadata.size,
entry.file_metadata.mode,
)
})
.collect();
Expand Down

0 comments on commit 51edd5c

Please sign in to comment.