mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- FEATURE: Display free disk space in torrent addition dialog
- Added some disambiguation for translators
This commit is contained in:
parent
c8e8306e0a
commit
6fcf25af52
5 changed files with 576 additions and 465 deletions
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue