Skip to content

Commit c22190f

Browse files
committed
Add patches for support Haiku (https://www.haiku-os.org)
1 parent 7419e93 commit c22190f

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

src/filesystemwatcher.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <sys/param.h>
1717
#include <sys/mount.h>
1818
#include <string.h>
19-
#else
19+
#elif !defined Q_WS_HAIKU
2020
#include <sys/vfs.h>
2121
#endif
2222
#endif
@@ -56,7 +56,7 @@ class FileSystemWatcher: public QFileSystemWatcher {
5656
QHash<QString, int> m_partialTorrents;
5757
QPointer<QTimer> m_partialTorrentTimer;
5858

59-
#ifndef Q_OS_WIN
59+
#if !defined Q_WS_WIN && !defined Q_WS_HAIKU
6060
private:
6161
static bool isNetworkFileSystem(QString path) {
6262
QString file = path;
@@ -145,7 +145,7 @@ class FileSystemWatcher: public QFileSystemWatcher {
145145
}
146146

147147
void addPath(const QString & path) {
148-
#ifndef Q_OS_WIN
148+
#if !defined Q_WS_WIN && !defined Q_WS_HAIKU
149149
QDir dir(path);
150150
if (!dir.exists())
151151
return;
@@ -167,7 +167,7 @@ class FileSystemWatcher: public QFileSystemWatcher {
167167
qDebug("FS Watching is watching %s in normal mode", qPrintable(path));
168168
QFileSystemWatcher::addPath(path);
169169
scanLocalFolder(path);
170-
#ifndef Q_OS_WIN
170+
#if !defined Q_WS_WIN && !defined Q_WS_HAIKU
171171
}
172172
#endif
173173
}

src/fs_utils.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)
5353
#include <sys/param.h>
5454
#include <sys/mount.h>
55+
#elif defined(Q_WS_HAIKU)
56+
#include <kernel/fs_info.h>
5557
#else
5658
#include <sys/vfs.h>
5759
#endif
@@ -289,6 +291,18 @@ long long fsutils::freeDiskSpaceOnPath(QString path) {
289291

290292
#ifndef Q_OS_WIN
291293
unsigned long long available;
294+
#ifdef Q_WS_HAIKU
295+
const QString statfs_path = dir_path.path()+"/.";
296+
dev_t device = dev_for_path (qPrintable(statfs_path));
297+
if (device >= 0) {
298+
fs_info info;
299+
if(fs_stat_dev(device, &info)==B_OK){
300+
available = ((unsigned long long)(info.free_blocks*info.block_size));
301+
return available;
302+
}
303+
}
304+
return -1;
305+
#else
292306
struct statfs stats;
293307
const QString statfs_path = dir_path.path()+"/.";
294308
const int ret = statfs (qPrintable(statfs_path), &stats) ;
@@ -299,6 +313,7 @@ long long fsutils::freeDiskSpaceOnPath(QString path) {
299313
} else {
300314
return -1;
301315
}
316+
#endif
302317
#else
303318
typedef BOOL (WINAPI *GetDiskFreeSpaceEx_t)(LPCTSTR,
304319
PULARGE_INTEGER,

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void sigtermHandler(int) {
156156
void sigsegvHandler(int) {
157157
signal(SIGABRT, 0);
158158
signal(SIGSEGV, 0);
159-
#ifndef Q_OS_WIN
159+
#if !defined Q_WS_WIN && !defined Q_WS_HAIKU
160160
std::cerr << "\n\n*************************************************************\n";
161161
std::cerr << "Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n";
162162
std::cerr << "qBittorrent version: " << VERSION << std::endl;
@@ -173,7 +173,7 @@ void sigsegvHandler(int) {
173173
void sigabrtHandler(int) {
174174
signal(SIGABRT, 0);
175175
signal(SIGSEGV, 0);
176-
#ifndef Q_OS_WIN
176+
#if !defined Q_WS_WIN && !defined Q_WS_HAIKU
177177
std::cerr << "\n\n*************************************************************\n";
178178
std::cerr << "Catching SIGABRT, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n";
179179
std::cerr << "qBittorrent version: " << VERSION << std::endl;

unixconf.pri

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ exists($$OUT_PWD/../conf.pri) {
1515
}
1616

1717
QMAKE_CXXFLAGS += -Wformat -Wformat-security
18-
QMAKE_LFLAGS_APP += -rdynamic
18+
!haiku {
19+
QMAKE_LFLAGS_APP += -rdynamic
20+
}
1921

2022
# Man page
2123
nox {

0 commit comments

Comments
 (0)