Skip to content

Commit e3df6c6

Browse files
authored
Update loader.rs
1 parent f36c2a3 commit e3df6c6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

vm/src/elf/loader.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
use crate::{elf::parser, error::VMError, memory::MemorySegmentImage};
4747

4848
use elf::{endian::LittleEndian, ElfBytes};
49-
use std::fs::File;
49+
use std::fs::{self, File};
5050
use std::path::Path;
5151

5252
use super::{error::ParserError, parser::ParsedElfData};
@@ -122,11 +122,7 @@ impl ElfFile {
122122
}
123123

124124
pub fn from_path<P: AsRef<Path> + ?Sized>(path: &P) -> Result<Self, VMError> {
125-
let file = File::open(path).map_err(Into::<ParserError>::into)?;
126-
127-
let data: Vec<u8> = std::io::Read::bytes(file)
128-
.map(|b| b.expect("Failed to read byte"))
129-
.collect();
125+
let data = fs::read(path.as_ref()).map_err(Into::<ParserError>::into)?;
130126
Self::from_bytes(data.as_slice())
131127
}
132128
}

0 commit comments

Comments
 (0)