diff --git a/src/builder.rs b/src/builder.rs index d7e756b1..9a9d65a9 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1062,19 +1062,34 @@ fn find_sparse_entries( file: &mut fs::File, stat: &fs::Metadata, ) -> io::Result> { - #[cfg(not(any(target_os = "android", target_os = "freebsd", target_os = "linux")))] + #[cfg(not(any( + target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "macos" + )))] { let _ = file; let _ = stat; Ok(None) } - #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] + #[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "macos" + ))] find_sparse_entries_seek(file, stat) } /// Implementation of `find_sparse_entries` using `SEEK_HOLE` and `SEEK_DATA`. -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] +#[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "linux", + target_os = "macos" +))] fn find_sparse_entries_seek( file: &mut fs::File, stat: &fs::Metadata, diff --git a/tests/all.rs b/tests/all.rs index eaeb839f..42b13f6a 100644 --- a/tests/all.rs +++ b/tests/all.rs @@ -1489,6 +1489,8 @@ fn writing_sparse() { assert!(data.len() <= 37 * 1024); // ext4 (defaults to 4k block size) #[cfg(target_os = "freebsd")] assert!(data.len() <= 273 * 1024); // UFS (defaults to 32k block size, last block isn't a hole) + #[cfg(target_os = "macos")] + assert!(data.len() <= 37 * 1024); // APFS (4k block size) let mut ar = Archive::new(&data[..]); let mut entries = ar.entries().unwrap();