multiarch: fix support for kfreebsd and hurd
authorYangfl <mmyangfl@gmail.com>
Tue, 12 Dec 2017 08:47:45 +0000 (16:47 +0800)
committerYangfl <mmyangfl@gmail.com>
Tue, 12 Dec 2017 09:19:32 +0000 (17:19 +0800)
Currently DFileSystemWatcher does not actually support non-Linux
platforms but provides a dummy file for win* and mac*, while
unconsidered condition prevents the entire library from building on
kFreebsd and Hurd, which are parts of platforms supported by Debian
project.

Resolves: https://bugs.debian.org/874137

Change-Id: I5ff455e8b1497492132599309ee9d5760b63694b

src/filesystem/dfilesystemwatcher_dummy.cpp [new file with mode: 0644]
src/filesystem/filesystem.pri
src/filesystem/private/dfilesystemwatcher_dummy_p.h [new file with mode: 0644]

diff --git a/src/filesystem/dfilesystemwatcher_dummy.cpp b/src/filesystem/dfilesystemwatcher_dummy.cpp
new file mode 100644 (file)
index 0000000..022c42e
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "dfilesystemwatcher.h"
+#include "private/dfilesystemwatcher_dummy_p.h"
+
+DCORE_BEGIN_NAMESPACE
+
+DFileSystemWatcherPrivate::DFileSystemWatcherPrivate(int fd, DFileSystemWatcher *qq)
+    : DObjectPrivate(qq)
+{
+
+}
+
+DFileSystemWatcherPrivate::~DFileSystemWatcherPrivate()
+{
+
+}
+
+/*!
+    \class DFileSystemWatcher
+    \inmodule QtCore
+    \brief The DFileSystemWatcher class provides an interface for monitoring files and directories for modifications.
+    \ingroup io
+    \since 4.2
+    \reentrant
+
+    DFileSystemWatcher monitors the file system for changes to files
+    and directories by watching a list of specified paths.
+
+    Call addPath() to watch a particular file or directory. Multiple
+    paths can be added using the addPaths() function. Existing paths can
+    be removed by using the removePath() and removePaths() functions.
+
+    DFileSystemWatcher examines each path added to it. Files that have
+    been added to the DFileSystemWatcher can be accessed using the
+    files() function, and directories using the directories() function.
+
+    The fileChanged() signal is emitted when a file has been modified,
+    renamed or removed from disk. Similarly, the directoryChanged()
+    signal is emitted when a directory or its contents is modified or
+    removed.  Note that DFileSystemWatcher stops monitoring files once
+    they have been renamed or removed from disk, and directories once
+    they have been removed from disk.
+
+    \note On systems running a Linux kernel without inotify support,
+    file systems that contain watched paths cannot be unmounted.
+
+    \note Windows CE does not support directory monitoring by
+    default as this depends on the file system driver installed.
+
+    \note The act of monitoring files and directories for
+    modifications consumes system resources. This implies there is a
+    limit to the number of files and directories your process can
+    monitor simultaneously. On all BSD variants, for
+    example, an open file descriptor is required for each monitored
+    file. Some system limits the number of open file descriptors to 256
+    by default. This means that addPath() and addPaths() will fail if
+    your process tries to add more than 256 files or directories to
+    the file system monitor. Also note that your process may have
+    other file descriptors open in addition to the ones for files
+    being monitored, and these other open descriptors also count in
+    the total. OS X uses a different backend and does not
+    suffer from this issue.
+
+
+    \sa QFile, QDir
+*/
+
+
+/*!
+    Constructs a new file system watcher object with the given \a parent.
+*/
+DFileSystemWatcher::DFileSystemWatcher(QObject *parent)
+    : QObject(parent)
+    , DObject()
+{
+
+}
+
+/*!
+    Constructs a new file system watcher object with the given \a parent
+    which monitors the specified \a paths list.
+*/
+DFileSystemWatcher::DFileSystemWatcher(const QStringList &paths, QObject *parent)
+    : DFileSystemWatcher(parent)
+{
+    addPaths(paths);
+}
+
+/*!
+    Destroys the file system watcher.
+*/
+DFileSystemWatcher::~DFileSystemWatcher()
+{ }
+
+/*!
+    Adds \a path to the file system watcher if \a path exists. The
+    path is not added if it does not exist, or if it is already being
+    monitored by the file system watcher.
+
+    If \a path specifies a directory, the directoryChanged() signal
+    will be emitted when \a path is modified or removed from disk;
+    otherwise the fileChanged() signal is emitted when \a path is
+    modified, renamed or removed.
+
+    If the watch was successful, true is returned.
+
+    Reasons for a watch failure are generally system-dependent, but
+    may include the resource not existing, access failures, or the
+    total watch count limit, if the platform has one.
+
+    \note There may be a system dependent limit to the number of
+    files and directories that can be monitored simultaneously.
+    If this limit is been reached, \a path will not be monitored,
+    and false is returned.
+
+    \sa addPaths(), removePath()
+*/
+bool DFileSystemWatcher::addPath(const QString &path)
+{
+    return false;
+}
+
+/*!
+    Adds each path in \a paths to the file system watcher. Paths are
+    not added if they not exist, or if they are already being
+    monitored by the file system watcher.
+
+    If a path specifies a directory, the directoryChanged() signal
+    will be emitted when the path is modified or removed from disk;
+    otherwise the fileChanged() signal is emitted when the path is
+    modified, renamed, or removed.
+
+    The return value is a list of paths that could not be watched.
+
+    Reasons for a watch failure are generally system-dependent, but
+    may include the resource not existing, access failures, or the
+    total watch count limit, if the platform has one.
+
+    \note There may be a system dependent limit to the number of
+    files and directories that can be monitored simultaneously.
+    If this limit has been reached, the excess \a paths will not
+    be monitored, and they will be added to the returned QStringList.
+
+    \sa addPath(), removePaths()
+*/
+QStringList DFileSystemWatcher::addPaths(const QStringList &paths)
+{
+    return QStringList();
+}
+
+/*!
+    Removes the specified \a path from the file system watcher.
+
+    If the watch is successfully removed, true is returned.
+
+    Reasons for watch removal failing are generally system-dependent,
+    but may be due to the path having already been deleted, for example.
+
+    \sa removePaths(), addPath()
+*/
+bool DFileSystemWatcher::removePath(const QString &path)
+{
+    return false;
+}
+
+/*!
+    Removes the specified \a paths from the file system watcher.
+
+    The return value is a list of paths which were not able to be
+    unwatched successfully.
+
+    Reasons for watch removal failing are generally system-dependent,
+    but may be due to the path having already been deleted, for example.
+
+    \sa removePath(), addPaths()
+*/
+QStringList DFileSystemWatcher::removePaths(const QStringList &paths)
+{
+    return QStringList();
+}
+
+/*!
+    \fn void DFileSystemWatcher::fileChanged(const QString &path)
+
+    This signal is emitted when the file at the specified \a path is
+    modified, renamed or removed from disk.
+
+    \sa directoryChanged()
+*/
+
+/*!
+    \fn void DFileSystemWatcher::directoryChanged(const QString &path)
+
+    This signal is emitted when the directory at a specified \a path
+    is modified (e.g., when a file is added or deleted) or removed
+    from disk. Note that if there are several changes during a short
+    period of time, some of the changes might not Q_EMIT this signal.
+    However, the last change in the sequence of changes will always
+    generate this signal.
+
+    \sa fileChanged()
+*/
+
+/*!
+    \fn QStringList DFileSystemWatcher::directories() const
+
+    Returns a list of paths to directories that are being watched.
+
+    \sa files()
+*/
+
+/*!
+    \fn QStringList DFileSystemWatcher::files() const
+
+    Returns a list of paths to files that are being watched.
+
+    \sa directories()
+*/
+
+QStringList DFileSystemWatcher::directories() const
+{
+    return QStringList();
+}
+
+QStringList DFileSystemWatcher::files() const
+{
+    return QStringList();
+}
+
+DCORE_END_NAMESPACE
+
+#include "moc_dfilesystemwatcher.cpp"
index 86d929bb52e99665b5a246028f20f51c759a8c66..d0e67f64e4f783affb6fff2905a679460f2a47bb 100644 (file)
@@ -23,9 +23,9 @@ linux {
 } else:win* {
     SOURCES += \
         $$PWD/dfilesystemwatcher_win.cpp
-} else:mac* {
+} else {
     SOURCES += \
-        $$PWD/dfilesystemwatcher_win.cpp
+        $$PWD/dfilesystemwatcher_dummy.cpp
 }
 
 includes.files += $$PWD/*.h
diff --git a/src/filesystem/private/dfilesystemwatcher_dummy_p.h b/src/filesystem/private/dfilesystemwatcher_dummy_p.h
new file mode 100644 (file)
index 0000000..67311b6
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DFILESYSTEMWATCHER_WIN_P_H
+#define DFILESYSTEMWATCHER_WIN_P_H
+
+#include "base/private/dobject_p.h"
+
+DCORE_BEGIN_NAMESPACE
+
+class DFileSystemWatcher;
+class DFileSystemWatcherPrivate : public DObjectPrivate
+{
+    Q_DECLARE_PUBLIC(DFileSystemWatcher)
+
+public:
+    DFileSystemWatcherPrivate(int fd, DFileSystemWatcher *qq);
+    ~DFileSystemWatcherPrivate();
+
+    // private slots
+    void _q_readFromInotify();
+};
+
+void DFileSystemWatcherPrivate::_q_readFromInotify()
+{
+
+}
+
+DCORE_END_NAMESPACE
+
+#endif // DFILESYSTEMWATCHER_WIN_P_H