Changeset View
Changeset View
Standalone View
Standalone View
src/engine/fsutils.cpp
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #include "fsutils.h" | 23 | #include "fsutils.h" | ||
24 | 24 | | |||
25 | #include <QDebug> | 25 | #include <QDebug> | ||
26 | 26 | | |||
27 | #ifdef Q_OS_LINUX | 27 | #ifdef Q_OS_LINUX | ||
28 | #include <errno.h> | 28 | #include <errno.h> | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> | ||
30 | #include <mntent.h> | | |||
31 | #include <sys/ioctl.h> | 30 | #include <sys/ioctl.h> | ||
32 | #include <fcntl.h> | 31 | #include <fcntl.h> | ||
33 | #endif | 32 | #endif | ||
34 | 33 | | |||
35 | using namespace Baloo; | 34 | using namespace Baloo; | ||
36 | 35 | | |||
37 | QString FSUtils::getDirectoryFileSystem(const QString &directory) | | |||
38 | { | | |||
39 | #ifndef Q_OS_LINUX | | |||
40 | return QString(); | | |||
41 | #else | | |||
42 | QString bestMatchPath; | | |||
43 | QString bestMatchFS; | | |||
44 | | ||||
45 | FILE *mtab = setmntent("/etc/mtab", "r"); | | |||
46 | if (!mtab) { | | |||
47 | return QString(); | | |||
48 | } | | |||
49 | while (mntent *mnt = getmntent(mtab)) { | | |||
50 | if (qstrcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0) { | | |||
51 | continue; | | |||
52 | } | | |||
53 | | ||||
54 | const QString dir = QString::fromLocal8Bit(mnt->mnt_dir); | | |||
55 | if (!directory.startsWith(dir) || dir.length() < bestMatchPath.length()) { | | |||
56 | continue; | | |||
57 | } | | |||
58 | | ||||
59 | bestMatchPath = dir; | | |||
60 | bestMatchFS = QString::fromLocal8Bit(mnt->mnt_type); | | |||
61 | } | | |||
62 | | ||||
63 | endmntent(mtab); | | |||
64 | | ||||
65 | return bestMatchFS; | | |||
66 | #endif | | |||
67 | } | | |||
68 | | ||||
69 | void FSUtils::disableCoW(const QString &path) | 36 | void FSUtils::disableCoW(const QString &path) | ||
70 | { | 37 | { | ||
71 | #ifndef Q_OS_LINUX | 38 | #ifndef Q_OS_LINUX | ||
72 | Q_UNUSED(path); | 39 | Q_UNUSED(path); | ||
73 | #else | 40 | #else | ||
74 | // from linux/fs.h, so that Baloo does not depend on Linux header files | 41 | // from linux/fs.h, so that Baloo does not depend on Linux header files | ||
75 | #ifndef FS_IOC_GETFLAGS | 42 | #ifndef FS_IOC_GETFLAGS | ||
76 | #define FS_IOC_GETFLAGS _IOR('f', 1, long) | 43 | #define FS_IOC_GETFLAGS _IOR('f', 1, long) | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |