Skip to content

Commit 897d4a0

Browse files
committed
utils: Add read_file_bytes()
Useful for reading (small) binary files. Signed-off-by: Daniel Silverstone <[email protected]>
1 parent 4ee47bb commit 897d4a0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/utils/utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ where
3737
})
3838
}
3939

40+
pub fn read_file_bytes(name: &'static str, path: &Path) -> Result<Vec<u8>> {
41+
fs::read(path).chain_err(|| ErrorKind::ReadingFile {
42+
name,
43+
path: PathBuf::from(path),
44+
})
45+
}
46+
4047
pub fn read_file(name: &'static str, path: &Path) -> Result<String> {
4148
fs::read_to_string(path).chain_err(|| ErrorKind::ReadingFile {
4249
name,

0 commit comments

Comments
 (0)