Merge pull request #4 from bootandy/blocks

Blocks
This commit is contained in:
andy boot
2018-03-22 16:37:05 -04:00
committed by GitHub
2 changed files with 9 additions and 13 deletions
+2 -2
View File
@@ -56,12 +56,14 @@ fn examine_dir(
match (file_type, maybe_size_and_inode) { match (file_type, maybe_size_and_inode) {
(Some(file_type), Some((size, inode))) => { (Some(file_type), Some((size, inode))) => {
let s = d.path().to_string_lossy().to_string(); let s = d.path().to_string_lossy().to_string();
if !apparent_size {
if let Some(inode_dev_pair) = inode { if let Some(inode_dev_pair) = inode {
if inodes.contains(&inode_dev_pair) { if inodes.contains(&inode_dev_pair) {
continue; continue;
} }
inodes.insert(inode_dev_pair); inodes.insert(inode_dev_pair);
} }
}
if d.path().is_dir() && !file_type.is_symlink() { if d.path().is_dir() && !file_type.is_symlink() {
let (hp, recursive) = let (hp, recursive) =
@@ -209,8 +211,6 @@ fn print_this_node(node_to_print: &Node, is_biggest: bool, depth: u8, indentatio
fn human_readable_number(size: u64) -> (String) { fn human_readable_number(size: u64) -> (String) {
let units = vec!["T", "G", "M", "K"]; //make static let units = vec!["T", "G", "M", "K"]; //make static
//return format!("{}B", size);
for (i, u) in units.iter().enumerate() { for (i, u) in units.iter().enumerate() {
let marker = 1024u64.pow((units.len() - i) as u32); let marker = 1024u64.pow((units.len() - i) as u32);
if size >= marker { if size >= marker {
+3 -7
View File
@@ -1,12 +1,8 @@
use std; use std;
#[cfg(not(any(target_os = "macos", target_os = "linux")))] fn get_block_size() -> u64 {
pub fn get_block_size() -> u64 { // All os specific implementations of MetatdataExt seem to define a block as 512 bytes
1024 // https://doc.rust-lang.org/std/os/linux/fs/trait.MetadataExt.html#tymethod.st_blocks
}
#[cfg(any(target_os = "macos", target_os = "linux"))]
pub fn get_block_size() -> u64 {
512 512
} }