lanzatool: don't open file to read metadata

This commit is contained in:
nikstur 2022-12-31 02:55:11 +01:00
parent 1c0438a003
commit b592d92744
1 changed files with 2 additions and 3 deletions

View File

@ -212,14 +212,13 @@ fn image_base(pe: &PE) -> u64 {
} }
fn file_size(path: impl AsRef<Path>) -> Result<u64> { fn file_size(path: impl AsRef<Path>) -> Result<u64> {
Ok(fs::File::open(&path) Ok(fs::metadata(&path)
.with_context(|| { .with_context(|| {
format!( format!(
"Failed to read file to calculate its size: {:?}", "Failed to read file metadata to calculate its size: {:?}",
path.as_ref() path.as_ref()
) )
})? })?
.metadata()?
.size()) .size())
} }