diff --git a/Cargo.lock b/Cargo.lock index 27e0be778..c7581aeec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,7 +792,7 @@ version = "0.0.1" dependencies = [ "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty-bytes 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "term_grid 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "termsize 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -971,6 +971,14 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "number_prefix" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "numfmt" version = "0.0.1" @@ -1065,15 +1073,6 @@ dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "pretty-bytes" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "printenv" version = "0.0.1" @@ -2123,13 +2122,13 @@ dependencies = [ "checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" "checksum num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3c2bd9b9d21e48e956b763c9f37134dc62d9e95da6edb3f672cacb6caf3cd3" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee" "checksum onig 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf9c54a94ac4d9f3eec22b189b8a727e2ded82aee21e8ae7ffbba2468739161b" "checksum onig_sys 67.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d894e8da3390097d99eb197eac2ec443277551388eff0f97c5f789933350ee" "checksum os_pipe 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f547689aea1f11fac90333d573854a8e3e52a9160df1c42aefa8cd16734a3c0" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum platform-info 0.1.0 (git+https://github.com/uutils/platform-info)" = "" -"checksum pretty-bytes 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "009d6edd2c1dbf2e1c0cd48a2f7766e03498d49ada7109a01c6911815c685316" "checksum proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cd07deb3c6d1d9ff827999c7f9b04cdfd66b1b17ae508e14fe47b620f2282ae0" "checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" diff --git a/src/ls/Cargo.toml b/src/ls/Cargo.toml index d861b7b7d..b0304b5ca 100644 --- a/src/ls/Cargo.toml +++ b/src/ls/Cargo.toml @@ -10,7 +10,7 @@ path = "ls.rs" [dependencies] getopts = "0.2.18" -pretty-bytes = "0.2.1" +number_prefix = "0.2.8" term_grid = "0.1.5" termsize = "0.1.4" time = "0.1.40" diff --git a/src/ls/ls.rs b/src/ls/ls.rs index 25bd83834..658be8d2c 100644 --- a/src/ls/ls.rs +++ b/src/ls/ls.rs @@ -9,12 +9,12 @@ // extern crate getopts; -extern crate pretty_bytes; extern crate term_grid; extern crate termsize; extern crate time; extern crate unicode_width; -use pretty_bytes::converter::convert; +extern crate number_prefix; +use number_prefix::{Standalone, Prefixed, decimal_prefix}; use term_grid::{Cell, Direction, Filling, Grid, GridOptions}; use time::{strftime, Timespec}; @@ -507,7 +507,10 @@ fn display_date(metadata: &Metadata, options: &getopts::Matches) -> String { fn display_file_size(metadata: &Metadata, options: &getopts::Matches) -> String { if options.opt_present("human-readable") { - convert(metadata.len() as f64) + match decimal_prefix(metadata.len() as f64) { + Standalone(bytes) => bytes.to_string(), + Prefixed(prefix, bytes) => format!("{:.2}{}", bytes, prefix).to_uppercase() + } } else { metadata.len().to_string() }