utils: Add read_file_bytes()
Useful for reading (small) binary files.
@@ -37,6 +37,13 @@ where
})
}
+pub fn read_file_bytes(name: &'static str, path: &Path) -> Result<Vec<u8>> {
+ fs::read(path).chain_err(|| ErrorKind::ReadingFile {
+ name,
+ path: PathBuf::from(path),
+ })
+}
+
pub fn read_file(name: &'static str, path: &Path) -> Result<String> {
fs::read_to_string(path).chain_err(|| ErrorKind::ReadingFile {
name,
