diff --git a/src/cmp.rs b/src/cmp.rs index 587d5cc..ce16a7f 100644 --- a/src/cmp.rs +++ b/src/cmp.rs @@ -11,10 +11,10 @@ use std::iter::Peekable; use std::process::ExitCode; use std::{cmp, fs, io}; -#[cfg(not(target_os = "windows"))] +#[cfg(unix)] use std::os::fd::{AsRawFd, FromRawFd}; -#[cfg(not(target_os = "windows"))] +#[cfg(unix)] use std::os::unix::fs::MetadataExt; #[cfg(target_os = "windows")] @@ -38,7 +38,7 @@ fn usage_string(executable: &str) -> String { format!("Usage: {executable} ") } -#[cfg(not(target_os = "windows"))] +#[cfg(unix)] fn is_stdout_dev_null() -> bool { let Ok(dev_null) = fs::metadata("/dev/null") else { return false; @@ -60,6 +60,11 @@ fn is_stdout_dev_null() -> bool { is_dev_null } +#[cfg(not(any(unix, target_os = "windows")))] +fn is_stdout_dev_null() -> bool { + false +} + pub fn parse_params>(mut opts: Peekable) -> Result { let Some(executable) = opts.next() else { return Err("Usage: ".to_string()); @@ -330,7 +335,7 @@ pub fn cmp(params: &Params) -> Result { if let (Ok(a_meta), Ok(b_meta)) = (fs::metadata(¶ms.from), fs::metadata(¶ms.to)) { #[cfg(not(target_os = "windows"))] - let (a_size, b_size) = (a_meta.size(), b_meta.size()); + let (a_size, b_size) = (a_meta.len(), b_meta.len()); #[cfg(target_os = "windows")] let (a_size, b_size) = (a_meta.file_size(), b_meta.file_size());