Prepare reading in files
This commit is contained in:
@@ -53,4 +53,14 @@ pub fn os_str_to_string(input: &std::ffi::OsStr, name: &str) -> Result<String> {
|
||||
|
||||
pub fn get_file_name_from_path_buf(input: &PathBuf, name: &str) -> Result<String> {
|
||||
os_str_to_string(Error::ok_or_new(input.file_name(), ||format!("No {} file name found", name), None)?, name)
|
||||
}
|
||||
|
||||
pub fn input_to_vec(input: Input) -> Result<Vec<u8>> {
|
||||
let mut data = Vec::new();
|
||||
|
||||
for byte in input.bytes() {
|
||||
data.push(Error::try_or_new(byte, None)?);
|
||||
}
|
||||
|
||||
Ok(data)
|
||||
}
|
Reference in New Issue
Block a user