summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/FileSize.cpp')
-rw-r--r--Swiften/Base/FileSize.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/Swiften/Base/FileSize.cpp b/Swiften/Base/FileSize.cpp
index 9b1fbba..a335337 100644
--- a/Swiften/Base/FileSize.cpp
+++ b/Swiften/Base/FileSize.cpp
@@ -1,23 +1,24 @@
/*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Base/FileSize.h>
+
#include <boost/format.hpp>
namespace Swift {
std::string formatSize(const boost::uintmax_t bytes) {
- static const char *siPrefix[] = {"k", "M", "G", "T", "P", "E", "Z", "Y", NULL};
- int power = 0;
- double engBytes = bytes;
- while (engBytes >= 1000) {
- ++power;
- engBytes = engBytes / 1000.0;
- }
- return str( boost::format("%.1lf %sB") % engBytes % (power > 0 ? siPrefix[power-1] : "") );
+ static const char *siPrefix[] = {"k", "M", "G", "T", "P", "E", "Z", "Y", nullptr};
+ int power = 0;
+ double engBytes = bytes;
+ while (engBytes >= 1000) {
+ ++power;
+ engBytes = engBytes / 1000.0;
+ }
+ return str( boost::format("%.1lf %sB") % engBytes % (power > 0 ? siPrefix[power-1] : "") );
}
}