diff options
author | Ronaldo Ferreira <ronaldo.ferreira@zalando.de> | 2018-04-17 15:29:30 +0200 |
---|---|---|
committer | Ignacio Nunez <nacho@ownyourbits.com> | 2018-05-10 21:47:12 +0200 |
commit | be55e95636126cb943be70a54154a55fb720c2b9 (patch) | |
tree | 8c6b2d5c309ca5bd3678ca200f03090e6ccdec37 | |
parent | 60b35ec74b880ea4501d378f4766579ab370e146 (diff) |
Make it work with macOSv0.2.7
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/lib.rs | 11 |
2 files changed, 11 insertions, 2 deletions
@@ -1,6 +1,6 @@ [package] name = "dutree" -version = "0.2.6" +version = "0.2.7" authors = ["nacho <nacho@ownyourbits.com>"] description = "Command line tool to analyze disk usage" repository = "https://github.com/nachoparker/dutree" @@ -52,11 +52,14 @@ use regex::Regex; use std::io; use std::path::{Path, PathBuf}; use std::fs; +#[cfg(target_os = "linux")] use std::os::linux::fs::MetadataExt; +#[cfg(target_os = "macos")] +use std::os::unix::fs::MetadataExt; use std::env; use std::collections::HashMap; -const VERSTR : &str = "v0.2.6"; +const VERSTR : &str = "v0.2.7"; const DEF_WIDTH : u16 = 80; pub enum XResult<T,S> { @@ -227,7 +230,10 @@ fn try_read_dir( path : &Path ) -> Option<fs::ReadDir> { fn try_bytes_from_path( path : &Path, usage_flag : bool ) -> u64 { match path.symlink_metadata() { + #[cfg(target_os = "linux")] Ok(metadata) => if usage_flag { metadata.st_blocks()*512 } else { metadata.st_size() }, + #[cfg(target_os = "macos")] + Ok(metadata) => if usage_flag { metadata.blocks()*512 } else { metadata.size() }, Err(err) => { print_io_error( path, err ); 0 @@ -480,7 +486,10 @@ fn color_from_path<'a>( path : &Path, color_dict : &'a HashMap<String, String> ) } let metadata = path.symlink_metadata(); if metadata.is_ok() { + #[cfg(target_os = "linux")] let mode = metadata.unwrap().st_mode(); + #[cfg(target_os = "macos")] + let mode = metadata.unwrap().mode(); if path.is_dir() { if mode & 0o002 != 0 { // dir other writable if let Some( col ) = color_dict.get( &"ow".to_string() ) { |