mirror of
https://github.com/joel16/NX-Shell.git
synced 2025-02-17 02:29:02 +00:00
16 lines
384 B
C++
16 lines
384 B
C++
#include <cstdio>
|
|
|
|
namespace Utils {
|
|
void GetSizeString(char *string, double size) {
|
|
int i = 0;
|
|
const char *units[] = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
|
|
|
|
while (size >= 1024.0f) {
|
|
size /= 1024.0f;
|
|
i++;
|
|
}
|
|
|
|
std::sprintf(string, "%.*f %s", (i == 0) ? 0 : 2, size, units[i]);
|
|
}
|
|
}
|