Qt 4.8
qfilesystemwatcher_win_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 #ifndef QFILESYSTEMWATCHER_WIN_P_H
43 #define QFILESYSTEMWATCHER_WIN_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists for the convenience
50 // of the QLibrary class. This header file may change from
51 // version to version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "qfilesystemwatcher_p.h"
57 
58 #ifndef QT_NO_FILESYSTEMWATCHER
59 
60 #include <qt_windows.h>
61 
62 #include <QtCore/qdatetime.h>
63 #include <QtCore/qfile.h>
64 #include <QtCore/qfileinfo.h>
65 #include <QtCore/qhash.h>
66 #include <QtCore/qmutex.h>
67 #include <QtCore/qvector.h>
68 
70 
72 
73 // Even though QWindowsFileSystemWatcherEngine is derived of QThread
74 // via QFileSystemWatcher, it does not start a thread.
75 // Instead QWindowsFileSystemWatcher creates QWindowsFileSystemWatcherEngineThreads
76 // to do the actually watching.
78 {
79  Q_OBJECT
80 public:
83 
84  QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
85  QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
86 
87  void stop();
88 
89 
90  class Handle
91  {
92  public:
95 
97  : handle(INVALID_HANDLE_VALUE), flags(0u)
98  { }
99  Handle(const Handle &other)
100  : handle(other.handle), flags(other.flags)
101  { }
102  };
103 
104  class PathInfo {
105  public:
108  bool isDir;
109 
110  // fileinfo bits
113  QFile::Permissions permissions;
115 
116  PathInfo &operator=(const QFileInfo &fileInfo)
117  {
118  ownerId = fileInfo.ownerId();
119  groupId = fileInfo.groupId();
120  permissions = fileInfo.permissions();
121  lastModified = fileInfo.lastModified();
122  return *this;
123  }
124 
125  bool operator!=(const QFileInfo &fileInfo) const
126  {
127  return (ownerId != fileInfo.ownerId()
128  || groupId != fileInfo.groupId()
129  || permissions != fileInfo.permissions()
130  || lastModified != fileInfo.lastModified());
131  }
132  };
133 private:
135 
136 };
137 
139 {
140  Q_OBJECT
141 
142 public:
145  void run();
146  void stop();
147  void wakeup();
148 
151  int msg;
152 
154 
156 
157 Q_SIGNALS:
158  void fileChanged(const QString &path, bool removed);
159  void directoryChanged(const QString &path, bool removed);
160 };
161 
162 #endif // QT_NO_FILESYSTEMWATCHER
163 
165 
166 #endif // QFILESYSTEMWATCHER_WIN_P_H
QList< QWindowsFileSystemWatcherEngineThread * > threads
virtual void run()
The starting point for the thread.
Definition: qthread.cpp:628
void fileChanged(const QString &path, bool removed)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
quint16 u
The QString class provides a Unicode character string.
Definition: qstring.h:83
QFile::Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permissions for the file.
Definition: qfileinfo.cpp:1228
#define Q_SIGNALS
Definition: qobjectdefs.h:72
QHash< QString, QWindowsFileSystemWatcherEngine::Handle > handleForDir
uint ownerId() const
Returns the id of the owner of the file.
Definition: qfileinfo.cpp:1144
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool operator!=(const QFileInfo &fileInfo) const
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
unsigned int uint
Definition: qglobal.h:996
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories)
void * HANDLE
Definition: qnamespace.h:1671
void directoryChanged(const QString &path, bool removed)
#define Q_OBJECT
Definition: qobjectdefs.h:157
QHash< HANDLE, QHash< QString, QWindowsFileSystemWatcherEngine::PathInfo > > pathInfoForHandle
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
uint groupId() const
Returns the id of the group the file belongs to.
Definition: qfileinfo.cpp:1183
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories)
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
The QThread class provides a platform-independent way to manage threads.
Definition: qthread.h:59
PathInfo & operator=(const QFileInfo &fileInfo)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QDateTime lastModified() const
Returns the date and time when the file was last modified.
Definition: qfileinfo.cpp:1296