Support LZ4 compression for external CMDs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use colored::*;
|
||||
use envmnt::{ExpandOptions, ExpansionType};
|
||||
use std::{boxed::Box, io::{BufRead, BufReader, BufWriter, Read, Write}, path::PathBuf, str::FromStr};
|
||||
use std::{boxed::Box, fs::OpenOptions, io::{BufRead, BufReader, BufWriter, Read, Write}, path::PathBuf, str::FromStr};
|
||||
|
||||
pub mod bits;
|
||||
pub mod compress;
|
||||
@@ -241,6 +241,13 @@ pub fn read_file_to_string(file_path: &PathBuf) -> Result<String, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_file(file_path: &PathBuf, data: Vec<u8>) -> Result<(), Error> {
|
||||
let mut file = OpenOptions::new().read(true).write(true).truncate(true).create(true).open(file_path)?;
|
||||
|
||||
file.write_all(data.as_slice())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn create_file_read_error<T>(file_path: &PathBuf, error: std::io::Error) -> Result<T, Error> {
|
||||
Err(Error::from_text(format!("Failed reading file {} with error: \"{}\"", file_path.display(), error)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user