We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
read_to_end
1 parent aee5a82 commit c3dcffeCopy full SHA for c3dcffe
espflash/src/cli/mod.rs
@@ -359,9 +359,9 @@ pub fn write_bin_to_flash(opts: WriteBinToFlashOpts) -> Result<()> {
359
flasher.board_info()?;
360
361
let mut f = File::open(&opts.bin_file).into_diagnostic()?;
362
- let metadata = fs::metadata(&opts.bin_file).into_diagnostic()?;
363
- let mut buffer = vec![0; metadata.len() as usize];
364
- f.read(&mut buffer).into_diagnostic()?;
+ let size = f.metadata().into_diagnostic()?.len();
+ let mut buffer = Vec::with_capacity(size.try_into().into_diagnostic()?);
+ f.read_to_end(&mut buffer).into_diagnostic()?;
365
366
flasher.write_bin_to_flash(opts.addr, &buffer)?;
367
Ok(())
0 commit comments