src/catar/encoder.rs: add verbose flags

This commit is contained in:
Dietmar Maurer
2019-03-04 08:01:09 +01:00
parent e0b8ce6424
commit 219ef0e6ca
4 changed files with 22 additions and 8 deletions

View File

@ -36,7 +36,7 @@ impl Drop for CaTarBackupStream {
impl CaTarBackupStream {
pub fn new(mut dir: Dir, path: PathBuf) -> Result<Self, Error> {
pub fn new(mut dir: Dir, path: PathBuf, verbose: bool) -> Result<Self, Error> {
let mut buffer = Vec::with_capacity(4096);
unsafe { buffer.set_len(buffer.capacity()); }
@ -44,7 +44,8 @@ impl CaTarBackupStream {
let child = thread::spawn(move|| {
let mut writer = unsafe { std::fs::File::from_raw_fd(tx) };
if let Err(err) = CaTarEncoder::encode(path, &mut dir, None, &mut writer) {
let device_list = vec![];
if let Err(err) = CaTarEncoder::encode(path, &mut dir, Some(device_list), &mut writer, verbose) {
eprintln!("catar encode failed - {}", err);
}
});
@ -54,12 +55,12 @@ impl CaTarBackupStream {
Ok(Self { pipe: Some(pipe), buffer, child: Some(child) })
}
pub fn open(dirname: &Path) -> Result<Self, Error> {
pub fn open(dirname: &Path, verbose: bool) -> Result<Self, Error> {
let dir = nix::dir::Dir::open(dirname, OFlag::O_DIRECTORY, Mode::empty())?;
let path = std::path::PathBuf::from(dirname);
Self::new(dir, path)
Self::new(dir, path, verbose)
}
}