fix build failure on wasm32-wasip1 target (#215)

Co-authored-by: viju <pocopepe@vijus-MacBook-Air.local>
This commit is contained in:
viju
2026-04-18 23:02:32 +05:30
committed by GitHub
parent 18c5533b82
commit a340afb6d1
+9 -4
View File
@@ -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} <from> <to>")
}
#[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<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Result<Params, String> {
let Some(executable) = opts.next() else {
return Err("Usage: <exe> <from> <to>".to_string());
@@ -330,7 +335,7 @@ pub fn cmp(params: &Params) -> Result<Cmp, String> {
if let (Ok(a_meta), Ok(b_meta)) = (fs::metadata(&params.from), fs::metadata(&params.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());