diff --git a/src/nix/path-info.cc b/src/nix/path-info.cc index ee48d483c..fa4f45fb4 100644 --- a/src/nix/path-info.cc +++ b/src/nix/path-info.cc @@ -4,8 +4,9 @@ #include "json.hh" #include "common-args.hh" -#include #include +#include +#include using namespace nix; @@ -67,20 +68,20 @@ struct CmdPathInfo : StorePathsCommand, MixJSON void printSize(int value) { if (!humanReadable) { - std::cout << '\t' << std::setw(11) << value; + std::cout << '\t' << boost::format("%11d") % value; return; } - static constexpr std::array idents = { - ' ', 'K', 'M', 'G', 'T', 'P' + static constexpr std::array idents = { + ' ', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' }; size_t power = 0; double res = value; - while (res > 1024) { + while (res > 1024 && power < idents.size()) { ++power; res /= 1024; } - std::cout << '\t' << std::setw(11) << std::setprecision(3) << res << idents[power]; + std::cout << '\t' << boost::format("%11.1f") % res << idents[power]; } void run(ref store, Paths storePaths) override