Qt 4.8
qfileinfo_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 QFILEINFO_P_H
43 #define QFILEINFO_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 purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "qfileinfo.h"
57 #include "qabstractfileengine.h"
58 #include "qdatetime.h"
59 #include "qatomic.h"
60 #include "qshareddata.h"
61 #include "qfilesystemengine_p.h"
62 
63 #include <QtCore/private/qfilesystementry_p.h>
64 #include <QtCore/private/qfilesystemmetadata_p.h>
65 
67 
69 {
70 public:
73  CachedSize =0x08, CachedPerms=0x80 };
74 
76  : QSharedData(), fileEngine(0),
77  cachedFlags(0),
79  cache_enabled(true), fileFlags(0), fileSize(0)
80  {}
81  inline QFileInfoPrivate(const QFileInfoPrivate &copy)
82  : QSharedData(copy),
83  fileEntry(copy.fileEntry),
84  metaData(copy.metaData),
85  fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)),
86  cachedFlags(0),
87 #ifndef QT_NO_FSFILEENGINE
88  isDefaultConstructed(false),
89 #else
91 #endif
93  {}
94  inline QFileInfoPrivate(const QString &file)
95  : fileEntry(QDir::fromNativeSeparators(file)),
96  fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)),
97  cachedFlags(0),
98 #ifndef QT_NO_FSFILEENGINE
99  isDefaultConstructed(false),
100 #else
102 #endif
103  cache_enabled(true), fileFlags(0), fileSize(0)
104  {
105  }
106 
108  : QSharedData(),
109  fileEntry(file),
110  metaData(data),
111  fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)),
112  cachedFlags(0),
113  isDefaultConstructed(false),
114  cache_enabled(true), fileFlags(0), fileSize(0)
115  {
116  //If the file engine is not null, this maybe a "mount point" for a custom file engine
117  //in which case we can't trust the metadata
118  if (fileEngine)
120  }
121 
122  inline void clearFlags() const {
123  fileFlags = 0;
124  cachedFlags = 0;
125  if (fileEngine)
127  }
128  inline void clear() {
129  metaData.clear();
130  clearFlags();
131  for (int i = QAbstractFileEngine::NFileNames - 1 ; i >= 0 ; --i)
132  fileNames[i].clear();
133  fileOwners[1].clear();
134  fileOwners[0].clear();
135  }
136 
137  uint getFileFlags(QAbstractFileEngine::FileFlags) const;
141 
144 
146 
148  mutable QString fileOwners[2];
149 
150  mutable uint cachedFlags : 30;
151  bool const isDefaultConstructed : 1; // QFileInfo is a default constructed instance
152  bool cache_enabled : 1;
153  mutable uint fileFlags;
154  mutable qint64 fileSize;
155  mutable QDateTime fileTimes[3];
156  inline bool getCachedFlag(uint c) const
157  { return cache_enabled ? (cachedFlags & c) : 0; }
158  inline void setCachedFlag(uint c) const
159  { if (cache_enabled) cachedFlags |= c; }
160 
161 };
162 
164 
165 #endif // QFILEINFO_P_H
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const
This function should return the set of OR&#39;d flags that are true for the file engine&#39;s file...
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void clearFlags() const
Definition: qfileinfo_p.h:122
QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data)
Definition: qfileinfo_p.h:107
bool getCachedFlag(uint c) const
Definition: qfileinfo_p.h:156
#define QT_NO_FSFILEENGINE
Definition: qconfig-nacl.h:78
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
FileName
These values are used to request a file name in a particular format.
The QString class provides a Unicode character string.
Definition: qstring.h:83
uint getFileFlags(QAbstractFileEngine::FileFlags) const
Definition: qfileinfo.cpp:126
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QString getFileOwner(QAbstractFileEngine::FileOwner own) const
Definition: qfileinfo.cpp:102
QDateTime fileTimes[3]
Definition: qfileinfo_p.h:155
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
__int64 qint64
Definition: qglobal.h:942
void setCachedFlag(uint c) const
Definition: qfileinfo_p.h:158
FileTime
These are used by the fileTime() function.
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
QString getFileName(QAbstractFileEngine::FileName) const
Definition: qfileinfo.cpp:50
The QSharedData class is a base class for shared data objects.
Definition: qshareddata.h:56
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
QString fileNames[QAbstractFileEngine::NFileNames]
Definition: qfileinfo_p.h:147
QFileInfoPrivate(const QFileInfoPrivate &copy)
Definition: qfileinfo_p.h:81
QDateTime & getFileTime(QAbstractFileEngine::FileTime) const
Definition: qfileinfo.cpp:187
QFileInfoPrivate(const QString &file)
Definition: qfileinfo_p.h:94
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151
QString fileOwners[2]
Definition: qfileinfo_p.h:148