From c5830c5d00083a40c592fa52d2c7ad140d9c0fe2 Mon Sep 17 00:00:00 2001 From: bootandy Date: Tue, 1 May 2018 13:59:48 +0100 Subject: [PATCH] Stop using target_os just use target_family target_family unix covers linux and mac and wraps up the call for inodes in a common interface. --- src/utils/platform.rs | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/utils/platform.rs b/src/utils/platform.rs index 9d0451a..c62c5c6 100644 --- a/src/utils/platform.rs +++ b/src/utils/platform.rs @@ -6,23 +6,7 @@ fn get_block_size() -> u64 { 512 } -#[cfg(target_os = "linux")] -pub fn get_metadata(d: &DirEntry, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> { - use std::os::linux::fs::MetadataExt; - match d.metadata().ok() { - Some(md) => { - let inode = Some((md.st_ino(), md.st_dev())); - if use_apparent_size { - Some((md.len(), inode)) - } else { - Some((md.st_blocks() * get_block_size(), inode)) - } - } - None => None, - } -} - -#[cfg(target_os = "unix")] +#[cfg(target_family = "unix")] pub fn get_metadata(d: &DirEntry, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> { use std::os::unix::fs::MetadataExt; match d.metadata().ok() { @@ -38,23 +22,7 @@ pub fn get_metadata(d: &DirEntry, use_apparent_size: bool) -> Option<(u64, Optio } } -#[cfg(target_os = "macos")] -pub fn get_metadata(d: &DirEntry, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> { - use std::os::macos::fs::MetadataExt; - match d.metadata().ok() { - Some(md) => { - let inode = Some((md.st_ino(), md.st_dev())); - if use_apparent_size { - Some((md.len(), inode)) - } else { - Some((md.st_blocks() * get_block_size(), inode)) - } - } - None => None, - } -} - -#[cfg(not(any(target_os = "linux", target_os = "unix", target_os = "macos")))] +#[cfg(not(target_family = "unix"))] pub fn get_metadata(d: &DirEntry, _apparent: bool) -> Option<(u64, Option<(u64, u64)>)> { match d.metadata().ok() { Some(md) => Some((md.len(), None)),