- FEATURE: Display free disk space in torrent addition dialog

- Added some disambiguation for translators
This commit is contained in:
Christophe Dumez 2009-08-17 13:17:52 +00:00
parent c8e8306e0a
commit 6fcf25af52
5 changed files with 576 additions and 465 deletions

View file

@ -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