Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,19 +1062,34 @@ fn find_sparse_entries(
file: &mut fs::File,
stat: &fs::Metadata,
) -> io::Result<Option<SparseEntries>> {
#[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,
Expand Down
2 changes: 2 additions & 0 deletions tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading