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
+6 -6
View File
@@ -56,11 +56,13 @@ fn examine_dir(
match (file_type, maybe_size_and_inode) {
(Some(file_type), Some((size, inode))) => {
let s = d.path().to_string_lossy().to_string();
if let Some(inode_dev_pair) = inode {
if inodes.contains(&inode_dev_pair) {
continue;
if !apparent_size {
if let Some(inode_dev_pair) = inode {
if inodes.contains(&inode_dev_pair) {
continue;
}
inodes.insert(inode_dev_pair);
}
inodes.insert(inode_dev_pair);
}
if d.path().is_dir() && !file_type.is_symlink() {
@@ -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) {
let units = vec!["T", "G", "M", "K"]; //make static
//return format!("{}B", size);
for (i, u) in units.iter().enumerate() {
let marker = 1024u64.pow((units.len() - i) as u32);
if size >= marker {
+3 -7
View File
@@ -1,12 +1,8 @@
use std;
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
pub fn get_block_size() -> u64 {
1024
}
#[cfg(any(target_os = "macos", target_os = "linux"))]
pub fn get_block_size() -> u64 {
fn get_block_size() -> u64 {
// All os specific implementations of MetatdataExt seem to define a block as 512 bytes
// https://doc.rust-lang.org/std/os/linux/fs/trait.MetadataExt.html#tymethod.st_blocks
512
}