mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 08:16:16 -07:00
Get rid of libboost-filesystem dependency if libtorrent >= v0.16.x is used
This commit is contained in:
parent
1b8a2bf7c1
commit
f6b7b8bd6e
7 changed files with 187 additions and 149 deletions
51
src/misc.cpp
51
src/misc.cpp
|
@ -38,7 +38,6 @@
|
|||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
#include <QSettings>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
#ifdef DISABLE_GUI
|
||||
#include <QCoreApplication>
|
||||
|
@ -63,7 +62,14 @@ const int UNLEN = 256;
|
|||
#include <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifndef Q_WS_WIN
|
||||
#if defined(Q_WS_MAC) || defined(Q_OS_FREEBSD)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#else
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
#else
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
|
@ -230,9 +236,44 @@ long long misc::freeDiskSpaceOnPath(QString path) {
|
|||
if(!dir_path.exists()) return -1;
|
||||
}
|
||||
Q_ASSERT(dir_path.exists());
|
||||
namespace fs = boost::filesystem;
|
||||
fs::space_info sp_in = fs::space(fs::path(dir_path.path().toLocal8Bit()));
|
||||
return sp_in.available;
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
unsigned long long available;
|
||||
struct statfs stats;
|
||||
const QString statfs_path = dir_path.path()+"/.";
|
||||
const int ret = statfs (qPrintable(statfs_path), &stats) ;
|
||||
if(ret == 0) {
|
||||
available = ((unsigned long long)stats.f_bavail) *
|
||||
((unsigned long long)stats.f_bsize) ;
|
||||
return available;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
typedef BOOL (WINAPI *GetDiskFreeSpaceEx_t)(LPCTSTR,
|
||||
PULARGE_INTEGER,
|
||||
PULARGE_INTEGER,
|
||||
PULARGE_INTEGER);
|
||||
GetDiskFreeSpaceEx_t
|
||||
pGetDiskFreeSpaceEx = (GetDiskFreeSpaceEx_t)::GetProcAddress
|
||||
(
|
||||
::GetModuleHandle(TEXT("kernel32.dll")),
|
||||
"GetDiskFreeSpaceExW"
|
||||
);
|
||||
if ( pGetDiskFreeSpaceEx )
|
||||
{
|
||||
ULARGE_INTEGER bytesFree, bytesTotal;
|
||||
unsigned long long *ret;
|
||||
if (pGetDiskFreeSpaceEx((LPCTSTR)(QDir::toNativeSeparators(dir_path.path())).utf16(), &bytesFree, &bytesTotal, NULL)) {
|
||||
ret = (unsigned long long*)&bytesFree;
|
||||
return *ret;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue