#include <sys/vfs.h> #include <sys/stat.h>
qulonglong getFreeSpace(const QString &path) { QString apath = QDir(path).absolutePath();
struct stat stst; struct statfs stfs;
if (::stat(apath.toLocal8Bit(),&stst) == -1) { return 0; } if (::statfs(apath.toLocal8Bit(),&stfs) == -1) { return 0; } return stfs.f_bavail * (stst.st_blksize); }
|