From: Guilherme Maciel Ferreira Date: Tue, 1 Feb 2011 13:18:16 +0000 (+0100) Subject: Replaced all ocurrences of format_kb() by nice_unit_format() X-Git-Tag: v2.6~86^2~10 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=76d6cba9f03d6320af9060cc169ebd172cec944c;p=libi2ncommon Replaced all ocurrences of format_kb() by nice_unit_format() --- diff --git a/src/stringfunc.cpp b/src/stringfunc.cpp index 73de2cb..def77a7 100644 --- a/src/stringfunc.cpp +++ b/src/stringfunc.cpp @@ -919,6 +919,7 @@ const string symbolFormatLong[MAX_SYMBOL_FORMATS] = { " YBytes" }; + string nice_unit_format( const int64_t input, const UnitSystem system, @@ -972,60 +973,6 @@ string nice_unit_format( } // eo nice_unit_format(int input) -string format_kb(long long bytes) -{ - int sizecount = 0; - long double calcTraffic = bytes; - - /* - * Solange durch 1024 Teilen bis - * der naechste Teilschritt < 1 waere oder - * Abbruch bei Maximalumrechnung ->TB - */ - while (calcTraffic > 1024 && sizecount<=6) { - calcTraffic = calcTraffic / 1024; - sizecount++; - } - - long double tmp; // round - tmp = calcTraffic*10; - tmp += 0.5; - tmp = (long long) (tmp); - tmp = (long double)(tmp)/(long double)(10); - calcTraffic = tmp; - - ostringstream out; - - out.setf (ios::fixed); - out.precision(1); - switch (sizecount) { - case 1: - out << calcTraffic << " KB"; - break; - case 2: - out << calcTraffic << " MB"; - break; - case 3: - out << calcTraffic << " GB"; - break; - case 4: - out << calcTraffic << " TB"; - break; - case 5: - out << calcTraffic << " PB"; - break; - case 6: - out << calcTraffic << " EB"; - break; - default: - out << calcTraffic << " B"; - break; - } - - return out.str(); -} - - string escape(const string &s) { string out(s); diff --git a/src/stringfunc.hxx b/src/stringfunc.hxx index 596f8c6..4c544ca 100644 --- a/src/stringfunc.hxx +++ b/src/stringfunc.hxx @@ -207,7 +207,6 @@ std::string nice_unit_format( const UnitSystem system = US_SI, const UnitSymbolFormat symbolformat = USF_LONG ); -std::string format_kb(long long kb); bool replace_all(std::string &base, const std::string *ist, const std::string *soll); bool replace_all(std::string &base, const char *ist, const char *soll);