use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
#[cfg(feature = "system")]
pub(crate) fn get_all_data_from_file(file: &mut File, size: usize) -> io::Result<Vec<u8>> {
use std::io::Seek;
let mut buf = Vec::with_capacity(size);
file.rewind()?;
file.read_to_end(&mut buf)?;
Ok(buf)
}
#[cfg(feature = "system")]
pub(crate) fn read_file_into(file: &mut File, buf: &mut Vec<u8>) -> io::Result<()> {
use std::io::Seek;
buf.clear();
file.rewind()?;
file.read_to_end(buf)?;
Ok(())
}
#[cfg(feature = "system")]
pub(crate) fn read_path_into<P: AsRef<Path>>(file_path: P, buf: &mut Vec<u8>) -> io::Result<()> {
let mut file = File::open(file_path.as_ref())?;
buf.clear();
file.read_to_end(buf)?;
Ok(())
}
#[cfg(any(feature = "disk", feature = "system"))]
pub(crate) fn get_all_utf8_data<P: AsRef<Path>>(file_path: P, size: usize) -> io::Result<String> {
let mut file = File::open(file_path.as_ref())?;
let mut buf = String::with_capacity(size);
file.read_to_string(&mut buf)?;
Ok(buf)
}