mirror of
https://github.com/polybar/polybar.git
synced 2026-02-19 20:55:39 +00:00
fs: Fix wrong size report
This commit is contained in:
@ -257,15 +257,16 @@ namespace string_util {
|
||||
/**
|
||||
* Create a filesize string by converting given bytes to highest unit possible
|
||||
*/
|
||||
string filesize(unsigned long long kbytes, size_t precision, bool fixed, const string& locale) {
|
||||
vector<string> suffixes{"TB", "GB", "MB"};
|
||||
string suffix{"KB"};
|
||||
double value = kbytes;
|
||||
while (!suffixes.empty() && (value /= 1024.0) >= 1024.0) {
|
||||
string filesize(unsigned long long bytes, size_t precision, bool fixed, const string& locale) {
|
||||
vector<string> suffixes{"TB", "GB", "MB", "KB"};
|
||||
string suffix{"B"};
|
||||
double value = bytes;
|
||||
while (!suffixes.empty() && value >= 1024.0) {
|
||||
suffix = suffixes.back();
|
||||
suffixes.pop_back();
|
||||
value /= 1024.0;
|
||||
}
|
||||
return floating_point(value, precision, fixed, locale) + " GB";
|
||||
return floating_point(value, precision, fixed, locale) + " " + suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user