1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2026-01-18 03:01:06 +00:00

du: only use snake case

This commit is contained in:
Alex Lyon 2017-12-10 10:03:14 -08:00
parent 2efd2b38be
commit e2e77f8c70
No known key found for this signature in database
GPG key ID: B517F04B325131B1

View file

@ -9,8 +9,6 @@
* file that was distributed with this source code.
*/
#![allow(non_snake_case)]
extern crate time;
#[macro_use]
@ -211,8 +209,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
let strs = if matches.free.is_empty() {vec!("./".to_owned())} else {matches.free.clone()};
let MB = if matches.opt_present("si") {1000 * 1000} else {1024 * 1024};
let KB = if matches.opt_present("si") {1000} else {1024};
let mb = if matches.opt_present("si") {1000 * 1000} else {1024 * 1024};
let kb = if matches.opt_present("si") {1000} else {1024};
let block_size = match matches.opt_str("block-size") {
Some(s) => {
@ -254,17 +252,17 @@ pub fn uumain(args: Vec<String>) -> i32 {
let convert_size = |size: u64| -> String {
if matches.opt_present("human-readable") || matches.opt_present("si") {
if size >= MB {
format!("{:.1}M", (size as f64) / (MB as f64))
} else if size >= KB {
format!("{:.1}K", (size as f64) / (KB as f64))
if size >= mb {
format!("{:.1}M", (size as f64) / (mb as f64))
} else if size >= kb {
format!("{:.1}K", (size as f64) / (kb as f64))
} else {
format!("{}B", size)
}
} else if matches.opt_present("k") {
format!("{}", ((size as f64) / (KB as f64)).ceil())
format!("{}", ((size as f64) / (kb as f64)).ceil())
} else if matches.opt_present("m") {
format!("{}", ((size as f64) / (MB as f64)).ceil())
format!("{}", ((size as f64) / (mb as f64)).ceil())
} else {
format!("{}", ((size as f64) / (block_size as f64)).ceil())
}