2014-10-18 11:07:17 -04:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2014-10-18 11:07:17 -04:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QStringListIterator>
|
|
|
|
|
|
|
|
#include "Utils.h"
|
|
|
|
|
|
|
|
QString NiceSizeFormat(s64 size)
|
|
|
|
{
|
2015-11-25 23:05:43 -05:00
|
|
|
QStringList list = {
|
|
|
|
QStringLiteral("KB"),
|
|
|
|
QStringLiteral("MB"),
|
|
|
|
QStringLiteral("GB"),
|
|
|
|
QStringLiteral("TB"),
|
|
|
|
QStringLiteral("PB"),
|
|
|
|
QStringLiteral("EB")
|
|
|
|
};
|
2014-10-18 11:07:17 -04:00
|
|
|
QStringListIterator i(list);
|
2015-11-25 23:05:43 -05:00
|
|
|
QString unit = QStringLiteral("b");
|
2014-10-18 11:07:17 -04:00
|
|
|
double num = size;
|
|
|
|
while (num >= 1024.0 && i.hasNext())
|
|
|
|
{
|
|
|
|
unit = i.next();
|
|
|
|
num /= 1024.0;
|
|
|
|
}
|
2015-11-25 23:05:43 -05:00
|
|
|
return QStringLiteral("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit);
|
2014-10-18 11:07:17 -04:00
|
|
|
}
|