This commit is contained in:
Jean-Francois Dockes 2015-12-01 17:26:44 +01:00
parent 27c0129c99
commit 813b87722b

View File

@ -161,8 +161,10 @@ bool fsocc(const string &path, int *pc, long long *avmbs)
&totalbytes, NULL)) { &totalbytes, NULL)) {
return false; return false;
} }
*pc = int(100 * double(freebytesavail) / double(totalbytes)); if (pc)
*avmbs = totalbytes / FSOCC_MB; *pc = int(100 * double(freebytesavail) / double(totalbytes));
if (avmbs)
*avmbs = totalbytes / FSOCC_MB;
return true; return true;
#else #else
#ifdef sun #ifdef sun
@ -184,14 +186,15 @@ bool fsocc(const string &path, int *pc, long long *avmbs)
if (FSOCC_TOTAVAIL > 0) { if (FSOCC_TOTAVAIL > 0) {
fpc = 100.0 * FSOCC_USED / FSOCC_TOTAVAIL; fpc = 100.0 * FSOCC_USED / FSOCC_TOTAVAIL;
} }
*pc = int(fpc); if (pc)
if (blocks) { *pc = int(fpc);
*blocks = 0; if (avmbs) {
*avmbs = 0;
if (buf.f_bsize > 0) { if (buf.f_bsize > 0) {
int ratio = buf.f_bsize > FSOCC_MB ? buf.f_bsize / FSOCC_MB : int ratio = buf.f_bsize > FSOCC_MB ? buf.f_bsize / FSOCC_MB :
FSOCC_MB / buf.f_bsize; FSOCC_MB / buf.f_bsize;
*blocks = buf.f_bsize > FSOCC_MB ? *avmbs = buf.f_bsize > FSOCC_MB ?
((long long)buf.f_bavail) * ratio : ((long long)buf.f_bavail) * ratio :
((long long)buf.f_bavail) / ratio; ((long long)buf.f_bavail) / ratio;
} }