Qt 4.8
qfilesystemwatcher_fsevents_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 
43 #ifndef FILEWATCHER_FSEVENTS_P_H
44 #define FILEWATCHER_FSEVENTS_P_H
45 
46 //
47 // W A R N I N G
48 // -------------
49 //
50 // This file is not part of the Qt API. It exists for the convenience
51 // of the QLibrary class. This header file may change from
52 // version to version without notice, or even be removed.
53 //
54 // We mean it.
55 //
56 
57 #include "qfilesystemwatcher_p.h"
58 
59 #ifndef QT_NO_FILESYSTEMWATCHER
60 
61 #include <QtCore/qmutex.h>
62 #include <QtCore/qwaitcondition.h>
63 #include <QtCore/qthread.h>
64 #include <QtCore/qhash.h>
65 #include <QtCore/qlinkedlist.h>
66 #include <private/qcore_mac_p.h>
67 #include <sys/stat.h>
68 
69 typedef struct __FSEventStream *FSEventStreamRef;
70 typedef const struct __FSEventStream *ConstFSEventStreamRef;
71 typedef const struct __CFArray *CFArrayRef;
72 typedef UInt32 FSEventStreamEventFlags;
73 typedef uint64_t FSEventStreamEventId;
74 
76 
77 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
78 // Yes, I use a stat64 element here. QFileInfo requires too much knowledge about implementation
79 // details to be used as a long-standing record. Since I'm going to have to store this information, I can
80 // do the stat myself too.
81 struct PathInfo {
82  PathInfo(const QString &path, const QByteArray &absPath)
83  : originalPath(path), absolutePath(absPath) {}
84  QString originalPath; // The path we need to emit
85  QByteArray absolutePath; // The path we need to stat.
86  struct ::stat64 savedInfo; // All the info for the path so we can compare it.
87 };
88 typedef QLinkedList<PathInfo> PathInfoList;
90 #endif
91 
93 {
94  Q_OBJECT
95 public:
97 
99 
100  QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
101  QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
102 
103  void stop();
104 
105 private:
107  void warmUpFSEvents();
108  void updateFiles();
109 
110  static void fseventsCallback(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents,
111  void *eventPaths, const FSEventStreamEventFlags eventFlags[],
112  const FSEventStreamEventId eventIds[]);
113  void run();
116  CFRunLoopRef threadsRunLoop;
120 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && !defined(Q_OS_IOS)
121  PathHash filePathInfoHash;
122  PathHash dirPathInfoHash;
123  void updateHash(PathHash &pathHash);
124  void updateList(PathInfoList &list, bool directory, bool emitSignals);
125 #endif
126 };
127 
128 #endif //QT_NO_FILESYSTEMWATCHER
129 
130 #endif
131 
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
QHash< int, QString > PathHash
Definition: qsettings.cpp:118
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
const struct __FSEventStream * ConstFSEventStreamRef
UInt32 FSEventStreamEventFlags
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
struct __FSEventStream * FSEventStreamRef
The QLinkedList class is a template class that provides linked lists.
Definition: qdatastream.h:63
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
#define Q_OBJECT
Definition: qobjectdefs.h:157
QFuture< T > run(Function function,...)
uint64_t FSEventStreamEventId
const struct __CFArray * CFArrayRef