diff --git a/src/archive/tar.rs b/src/archive/tar.rs index 101a0e4..f183698 100644 --- a/src/archive/tar.rs +++ b/src/archive/tar.rs @@ -19,7 +19,11 @@ use crate::{ /// Unpacks the archive given by `archive` into the folder given by `into`. /// Assumes that output_folder is empty -pub fn unpack_archive(reader: Box, output_folder: &Path, mut out: impl Write) -> crate::Result> { +pub fn unpack_archive( + reader: Box, + output_folder: &Path, + mut log_out: impl Write, +) -> crate::Result> { assert!(output_folder.read_dir().expect("dir exists").count() == 0); let mut archive = tar::Archive::new(reader); @@ -36,7 +40,7 @@ pub fn unpack_archive(reader: Box, output_folder: &Path, mut out: impl // and so on info!( - @out, + @log_out, inaccessible, "{:?} extracted. ({})", utils::strip_cur_dir(&output_folder.join(file.path()?)), Bytes::new(file.size()) @@ -82,7 +86,7 @@ pub fn build_archive_from_paths( input_filenames: &[PathBuf], writer: W, file_visibility_policy: FileVisibilityPolicy, - mut out: D, + mut log_out: D, ) -> crate::Result where W: Write, @@ -104,7 +108,7 @@ where // little importance for most users, but would generate lots of // spoken text for users using screen readers, braille displays // and so on - info!(@out, inaccessible, "Compressing '{}'.", utils::to_utf(path)); + info!(@log_out, inaccessible, "Compressing '{}'.", utils::to_utf(path)); if path.is_dir() { builder.append_dir(path, path)?; diff --git a/src/archive/zip.rs b/src/archive/zip.rs index ed27b80..9b18318 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -27,7 +27,11 @@ use crate::{ /// Unpacks the archive given by `archive` into the folder given by `output_folder`. /// Assumes that output_folder is empty -pub fn unpack_archive(mut archive: ZipArchive, output_folder: &Path, mut out: D) -> crate::Result> +pub fn unpack_archive( + mut archive: ZipArchive, + output_folder: &Path, + mut log_out: D, +) -> crate::Result> where R: Read + Seek, D: Write, @@ -53,7 +57,7 @@ where // importance for most users, but would generate lots of // spoken text for users using screen readers, braille displays // and so on - info!(@out, inaccessible, "File {} extracted to \"{}\"", idx, file_path.display()); + info!(@log_out, inaccessible, "File {} extracted to \"{}\"", idx, file_path.display()); fs::create_dir_all(&file_path)?; } _is_file @ false => { @@ -66,7 +70,7 @@ where // same reason is in _is_dir: long, often not needed text info!( - @out, + @log_out, inaccessible, "{:?} extracted. ({})", file_path.display(), Bytes::new(file.size()) @@ -133,7 +137,7 @@ pub fn build_archive_from_paths( input_filenames: &[PathBuf], writer: W, file_visibility_policy: FileVisibilityPolicy, - mut out: D, + mut log_out: D, ) -> crate::Result where W: Write + Seek, @@ -173,7 +177,7 @@ where // little importance for most users, but would generate lots of // spoken text for users using screen readers, braille displays // and so on - info!(@out, inaccessible, "Compressing '{}'.", to_utf(path)); + info!(@log_out, inaccessible, "Compressing '{}'.", to_utf(path)); let metadata = match path.metadata() { Ok(metadata) => metadata, diff --git a/src/macros.rs b/src/macros.rs index 6150a2b..40f89e7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -18,7 +18,7 @@ use crate::accessible::is_running_in_accessible_mode; /// ability to skip some lines deemed not important like a seeing person would. /// /// By default `info` outputs to Stdout, if you want to specify the output you can use -/// `@out` modifier +/// `@log_out` modifier #[macro_export] macro_rules! info { @@ -27,24 +27,24 @@ macro_rules! info { (accessible, $($arg:tt)*) => { info!(@::std::io::stdout(), accessible, $($arg)*); }; - (@$out: expr, accessible, $($arg:tt)*) => { - let out = &mut $out; + (@$log_out: expr, accessible, $($arg:tt)*) => { + let log_out = &mut $log_out; // if in ACCESSIBLE mode, suppress the "[INFO]" and just print the message if !$crate::accessible::is_running_in_accessible_mode() { - $crate::macros::_info_helper(out); + $crate::macros::_info_helper(log_out); } - writeln!(out, $($arg)*).unwrap(); + writeln!(log_out, $($arg)*).unwrap(); }; // Inccessible (long/no important) info message. // Print info message if ACCESSIBLE is not turned on (inaccessible, $($arg:tt)*) => { info!(@::std::io::stdout(), inaccessible, $($arg)*); }; - (@$out: expr, inaccessible, $($arg:tt)*) => { + (@$log_out: expr, inaccessible, $($arg:tt)*) => { if !$crate::accessible::is_running_in_accessible_mode() { - let out = &mut $out; - $crate::macros::_info_helper(out); - writeln!(out, $($arg)*).unwrap(); + let log_out = &mut $log_out; + $crate::macros::_info_helper(log_out); + writeln!(log_out, $($arg)*).unwrap(); } }; }