mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 22:47:21 -06:00
- FEATURE: Display free disk space in torrent addition dialog
- Added some disambiguation for translators
This commit is contained in:
22
src/misc.h
22
src/misc.h
@@ -42,6 +42,10 @@
|
||||
#include <QPair>
|
||||
#include <QThread>
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
using namespace libtorrent;
|
||||
|
||||
@@ -92,6 +96,24 @@ public:
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
static unsigned long long freeDiskSpaceOnPath(QString path) {
|
||||
#ifndef Q_WS_WIN
|
||||
unsigned long long available;
|
||||
struct statfs stats;
|
||||
int ret = statfs ((path+"/.").toUtf8().data(), &stats) ;
|
||||
if(ret == 0) {
|
||||
available = ((unsigned long long)stats.f_bavail) *
|
||||
((unsigned long long)stats.f_bsize) ;
|
||||
return available;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
// return best userfriendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||
// use Binary prefix standards from IEC 60027-2
|
||||
// see http://en.wikipedia.org/wiki/Kilobyte
|
||||
|
||||
Reference in New Issue
Block a user