1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 18:54:31 +03:00

Fixed display of card size and free space for numbers over 4 GB.

The result was stored in a 64-bit integer, but the computation was done in 32 bits...
This commit is contained in:
Maarten ter Huurne 2010-06-18 03:16:44 +02:00
parent d3b094e1b5
commit 988439605d

View File

@ -1907,8 +1907,11 @@ string GMenu2X::getDiskFree() {
int ret = statvfs("/card", &b);
if (ret==0) {
unsigned long long free = b.f_bfree * b.f_bsize / 1048576;
unsigned long long total = b.f_blocks * b.f_frsize / 1048576;
// Make sure that the multiplication happens in 64 bits.
unsigned long long free =
((unsigned long long)b.f_bfree * b.f_bsize) / 1048576;
unsigned long long total =
((unsigned long long)b.f_blocks * b.f_frsize) / 1048576;
ss << free << "/" << total << "MB";
ss >> df;
} else cout << "\033[0;34mGMENU2X:\033[0;31m statvfs failed with error '" << strerror(errno) << "'\033[0m" << endl;