PackageInstaller: use string_for_size instead of a custom function.

This commit is contained in:
Augustin Cavalier
2015-04-26 20:17:26 -04:00
parent e5ab3b0900
commit 0cec9e7680
+2 -19
View File
@@ -27,6 +27,7 @@
#include <Path.h> #include <Path.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <StringForSize.h>
#include <TextView.h> #include <TextView.h>
#include <Volume.h> #include <Volume.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
@@ -47,24 +48,6 @@ const float kMaxDescHeight = 125.0f;
const uint32 kSeparatorIndex = 3; const uint32 kSeparatorIndex = 3;
static void
convert_size(uint64 size, char *buffer, uint32 n)
{
if (size < 1024)
snprintf(buffer, n, B_TRANSLATE("%llu bytes"), size);
else if (size < 1024 * 1024)
snprintf(buffer, n, B_TRANSLATE("%.1f KiB"), size / 1024.0f);
else if (size < 1024 * 1024 * 1024)
snprintf(buffer, n, B_TRANSLATE("%.1f MiB"),
size / (1024.0f * 1024.0f));
else {
snprintf(buffer, n, B_TRANSLATE("%.1f GiB"),
size / (1024.0f * 1024.0f * 1024.0f));
}
}
// #pragma mark - // #pragma mark -
@@ -684,7 +667,7 @@ PackageView::_NamePlusSizeString(BString baseName, size_t size,
const char* format) const const char* format) const
{ {
char sizeString[48]; char sizeString[48];
convert_size(size, sizeString, sizeof(sizeString)); string_for_size(size, sizeString, sizeof(sizeString));
BString name(format); BString name(format);
name.ReplaceAll("%name%", baseName); name.ReplaceAll("%name%", baseName);