use super::*;
pub fn write_to_file(file_path: &str, content: &[u8]) -> Result<(), Error> {
if let Some(parent_dir) = Path::new(file_path).parent() {
create_dir_all(parent_dir)?;
}
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(file_path)
.and_then(|mut file: File| Write::write_all(&mut file, content))
}
pub fn append_to_file(file_path: &str, content: &[u8]) -> Result<(), Error> {
if let Some(parent_dir) = Path::new(file_path).parent() {
create_dir_all(parent_dir)?;
}
OpenOptions::new()
.create(true)
.append(true)
.open(file_path)
.and_then(|mut file: File| Write::write_all(&mut file, content))
}