lanzatool: improve error msg for file_size

This commit is contained in:
nikstur 2022-12-30 03:38:57 +01:00
parent a341baa09a
commit d4c5af23fe
1 changed files with 9 additions and 1 deletions

View File

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