Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QFileInfoPrivate Class Reference

#include <qfileinfo_p.h>

Inheritance diagram for QFileInfoPrivate:
QSharedData

Public Types

enum  {
  CachedFileFlags =0x01, CachedLinkTypeFlag =0x02, CachedBundleTypeFlag =0x04, CachedMTime =0x10,
  CachedCTime =0x20, CachedATime =0x40, CachedSize =0x08, CachedPerms =0x80
}
 

Public Functions

void clear ()
 
void clearFlags () const
 
bool getCachedFlag (uint c) const
 
uint getFileFlags (QAbstractFileEngine::FileFlags) const
 
QString getFileName (QAbstractFileEngine::FileName) const
 
QString getFileOwner (QAbstractFileEngine::FileOwner own) const
 
QDateTimegetFileTime (QAbstractFileEngine::FileTime) const
 
 QFileInfoPrivate ()
 
 QFileInfoPrivate (const QFileInfoPrivate &copy)
 
 QFileInfoPrivate (const QString &file)
 
 QFileInfoPrivate (const QFileSystemEntry &file, const QFileSystemMetaData &data)
 
void setCachedFlag (uint c) const
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Public Variables

bool cache_enabled: 1
 
uint cachedFlags: 30
 
QScopedPointer< QAbstractFileEngine > const fileEngine
 
QFileSystemEntry fileEntry
 
uint fileFlags
 
QString fileNames [QAbstractFileEngine::NFileNames]
 
QString fileOwners [2]
 
qint64 fileSize
 
QDateTime fileTimes [3]
 
bool const isDefaultConstructed: 1
 
QFileSystemMetaData metaData
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Definition at line 68 of file qfileinfo_p.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
CachedFileFlags 
CachedLinkTypeFlag 
CachedBundleTypeFlag 
CachedMTime 
CachedCTime 
CachedATime 
CachedSize 
CachedPerms 

Definition at line 71 of file qfileinfo_p.h.

Constructors and Destructors

◆ QFileInfoPrivate() [1/4]

QFileInfoPrivate::QFileInfoPrivate ( )
inline

Definition at line 75 of file qfileinfo_p.h.

76  : QSharedData(), fileEngine(0),
77  cachedFlags(0),
79  cache_enabled(true), fileFlags(0), fileSize(0)
80  {}
QSharedData()
Constructs a QSharedData object with a reference count of 0.
Definition: qshareddata.h:61
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151

◆ QFileInfoPrivate() [2/4]

QFileInfoPrivate::QFileInfoPrivate ( const QFileInfoPrivate copy)
inline

Definition at line 81 of file qfileinfo_p.h.

82  : QSharedData(copy),
83  fileEntry(copy.fileEntry),
84  metaData(copy.metaData),
86  cachedFlags(0),
87 #ifndef QT_NO_FSFILEENGINE
88  isDefaultConstructed(false),
89 #else
91 #endif
93  {}
QSharedData()
Constructs a QSharedData object with a reference count of 0.
Definition: qshareddata.h:61
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
static QAbstractFileEngine * resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaData &data)
Resolves the entry (see QDir::searchPaths) and returns an engine for it, but never a QFSFileEngine...
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151

◆ QFileInfoPrivate() [3/4]

QFileInfoPrivate::QFileInfoPrivate ( const QString file)
inline

Definition at line 94 of file qfileinfo_p.h.

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  }
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
static QAbstractFileEngine * resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaData &data)
Resolves the entry (see QDir::searchPaths) and returns an engine for it, but never a QFSFileEngine...
static QString fromNativeSeparators(const QString &pathName)
Returns pathName using &#39;/&#39; as file separator.
Definition: qdir.cpp:848
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151

◆ QFileInfoPrivate() [4/4]

QFileInfoPrivate::QFileInfoPrivate ( const QFileSystemEntry file,
const QFileSystemMetaData data 
)
inline

Definition at line 107 of file qfileinfo_p.h.

108  : QSharedData(),
109  fileEntry(file),
110  metaData(data),
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  }
QSharedData()
Constructs a QSharedData object with a reference count of 0.
Definition: qshareddata.h:61
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
static QAbstractFileEngine * resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaData &data)
Resolves the entry (see QDir::searchPaths) and returns an engine for it, but never a QFSFileEngine...
bool const isDefaultConstructed
Definition: qfileinfo_p.h:151

Functions

◆ clear()

void QFileInfoPrivate::clear ( )
inline

Definition at line 128 of file qfileinfo_p.h.

128  {
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  }
void clearFlags() const
Definition: qfileinfo_p.h:122
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
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
QString fileOwners[2]
Definition: qfileinfo_p.h:148

◆ clearFlags()

void QFileInfoPrivate::clearFlags ( ) const
inline

Definition at line 122 of file qfileinfo_p.h.

Referenced by clear(), and getFileTime().

122  {
123  fileFlags = 0;
124  cachedFlags = 0;
125  if (fileEngine)
127  }
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

◆ getCachedFlag()

bool QFileInfoPrivate::getCachedFlag ( uint  c) const
inline

Definition at line 156 of file qfileinfo_p.h.

Referenced by getFileFlags(), and getFileTime().

157  { return cache_enabled ? (cachedFlags & c) : 0; }
unsigned char c[8]
Definition: qnumeric_p.h:62

◆ getFileFlags()

uint QFileInfoPrivate::getFileFlags ( QAbstractFileEngine::FileFlags  request) const

Definition at line 126 of file qfileinfo.cpp.

Referenced by clear().

127 {
128  Q_ASSERT(fileEngine); // should never be called when using the native FS
129  // We split the testing into tests for for LinkType, BundleType, PermsMask
130  // and the rest.
131  // Tests for file permissions on Windows can be slow, expecially on network
132  // paths and NTFS drives.
133  // In order to determine if a file is a symlink or not, we have to lstat().
134  // If we're not interested in that information, we might as well avoid one
135  // extra syscall. Bundle detecton on Mac can be slow, expecially on network
136  // paths, so we separate out that as well.
137 
138  QAbstractFileEngine::FileFlags req = 0;
139  uint cachedFlags = 0;
140 
145  req &= (~QAbstractFileEngine::LinkType);
146  req &= (~QAbstractFileEngine::BundleType);
147 
148  cachedFlags |= CachedFileFlags;
149  }
150 
151  if (request & QAbstractFileEngine::LinkType) {
154  cachedFlags |= CachedLinkTypeFlag;
155  }
156  }
157 
158  if (request & QAbstractFileEngine::BundleType) {
161  cachedFlags |= CachedBundleTypeFlag;
162  }
163  }
164  }
165 
166  if (request & QAbstractFileEngine::PermsMask) {
167  if (!getCachedFlag(CachedPerms)) {
169  cachedFlags |= CachedPerms;
170  }
171  }
172 
173  if (req) {
174  if (cache_enabled)
175  req &= (~QAbstractFileEngine::Refresh);
176  else
178 
179  QAbstractFileEngine::FileFlags flags = fileEngine->fileFlags(req);
180  fileFlags |= uint(flags);
181  setCachedFlag(cachedFlags);
182  }
183 
184  return fileFlags & request;
185 }
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
bool getCachedFlag(uint c) const
Definition: qfileinfo_p.h:156
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QAbstractFileEngine class provides an abstraction for accessing the filesystem.
unsigned int uint
Definition: qglobal.h:996
void setCachedFlag(uint c) const
Definition: qfileinfo_p.h:158

◆ getFileName()

QString QFileInfoPrivate::getFileName ( QAbstractFileEngine::FileName  name) const

Definition at line 50 of file qfileinfo.cpp.

Referenced by clear().

51 {
52  if (cache_enabled && !fileNames[(int)name].isNull())
53  return fileNames[(int)name];
54 
55  QString ret;
56  if (fileEngine == 0) { // local file; use the QFileSystemEngine directly
57  switch (name) {
61  if (cache_enabled) { // be smart and store both
64  }
66  ret = entry.filePath();
67  else
68  ret = entry.path();
69  break;
70  }
73  break;
76  break;
80  if (cache_enabled) { // be smart and store both
83  }
85  ret = entry.filePath();
86  else
87  ret = entry.path();
88  break;
89  }
90  default: break;
91  }
92  } else {
93  ret = fileEngine->fileName(name);
94  }
95  if (ret.isNull())
96  ret = QLatin1String("");
97  if (cache_enabled)
98  fileNames[(int)name] = ret;
99  return ret;
100 }
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
virtual QString fileName(FileName file=DefaultName) const
Return the file engine&#39;s current file name in the format specified by file.
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QFileSystemEntry absoluteName(const QFileSystemEntry &entry)
const char * name
static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data)
static QString bundleName(const QFileSystemEntry &entry)
QString fileNames[QAbstractFileEngine::NFileNames]
Definition: qfileinfo_p.h:147
QString filePath() const
QString path() const
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)

◆ getFileOwner()

QString QFileInfoPrivate::getFileOwner ( QAbstractFileEngine::FileOwner  own) const

Definition at line 102 of file qfileinfo.cpp.

Referenced by clear().

103 {
104  if (cache_enabled && !fileOwners[(int)own].isNull())
105  return fileOwners[(int)own];
106  QString ret;
107  if (fileEngine == 0) {
108  switch (own) {
111  break;
114  break;
115  }
116  } else {
117  ret = fileEngine->owner(own);
118  }
119  if (ret.isNull())
120  ret = QLatin1String("");
121  if (cache_enabled)
122  fileOwners[(int)own] = ret;
123  return ret;
124 }
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
QFileSystemEntry fileEntry
Definition: qfileinfo_p.h:142
static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
virtual QString owner(FileOwner) const
If owner is OwnerUser return the name of the user who owns the file.
QFileSystemMetaData metaData
Definition: qfileinfo_p.h:143
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
QString fileOwners[2]
Definition: qfileinfo_p.h:148
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300

◆ getFileTime()

QDateTime & QFileInfoPrivate::getFileTime ( QAbstractFileEngine::FileTime  request) const

Definition at line 187 of file qfileinfo.cpp.

Referenced by clear().

188 {
189  Q_ASSERT(fileEngine); // should never be called when using the native FS
190  if (!cache_enabled)
191  clearFlags();
192  uint cf;
193  if (request == QAbstractFileEngine::CreationTime)
194  cf = CachedCTime;
195  else if (request == QAbstractFileEngine::ModificationTime)
196  cf = CachedMTime;
197  else
198  cf = CachedATime;
199  if (!getCachedFlag(cf)) {
200  fileTimes[request] = fileEngine->fileTime(request);
201  setCachedFlag(cf);
202  }
203  return fileTimes[request];
204 }
QScopedPointer< QAbstractFileEngine > const fileEngine
Definition: qfileinfo_p.h:145
void clearFlags() const
Definition: qfileinfo_p.h:122
bool getCachedFlag(uint c) const
Definition: qfileinfo_p.h:156
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QDateTime fileTimes[3]
Definition: qfileinfo_p.h:155
unsigned int uint
Definition: qglobal.h:996
void setCachedFlag(uint c) const
Definition: qfileinfo_p.h:158
virtual QDateTime fileTime(FileTime time) const
If time is CreationTime, return when the file was created.

◆ setCachedFlag()

void QFileInfoPrivate::setCachedFlag ( uint  c) const
inline

Definition at line 158 of file qfileinfo_p.h.

Referenced by getFileFlags(), and getFileTime().

159  { if (cache_enabled) cachedFlags |= c; }
unsigned char c[8]
Definition: qnumeric_p.h:62

Properties

◆ cache_enabled

bool QFileInfoPrivate::cache_enabled

◆ cachedFlags

uint QFileInfoPrivate::cachedFlags
mutable

Definition at line 150 of file qfileinfo_p.h.

Referenced by clearFlags(), getCachedFlag(), getFileFlags(), and setCachedFlag().

◆ fileEngine

QScopedPointer<QAbstractFileEngine> const QFileInfoPrivate::fileEngine

◆ fileEntry

QFileSystemEntry QFileInfoPrivate::fileEntry

◆ fileFlags

uint QFileInfoPrivate::fileFlags
mutable

Definition at line 153 of file qfileinfo_p.h.

Referenced by clearFlags(), and getFileFlags().

◆ fileNames

QString QFileInfoPrivate::fileNames[QAbstractFileEngine::NFileNames]
mutable

Definition at line 147 of file qfileinfo_p.h.

Referenced by clear(), and getFileName().

◆ fileOwners

QString QFileInfoPrivate::fileOwners[2]
mutable

Definition at line 148 of file qfileinfo_p.h.

Referenced by clear(), and getFileOwner().

◆ fileSize

qint64 QFileInfoPrivate::fileSize
mutable

Definition at line 154 of file qfileinfo_p.h.

◆ fileTimes

QDateTime QFileInfoPrivate::fileTimes[3]
mutable

Definition at line 155 of file qfileinfo_p.h.

Referenced by getFileTime().

◆ isDefaultConstructed

bool const QFileInfoPrivate::isDefaultConstructed

Definition at line 151 of file qfileinfo_p.h.

Referenced by QFileInfo::makeAbsolute(), and QFileInfo::operator==().

◆ metaData

QFileSystemMetaData QFileInfoPrivate::metaData
mutable

Definition at line 143 of file qfileinfo_p.h.

Referenced by clear(), getFileName(), getFileOwner(), and QFileInfoPrivate().


The documentation for this class was generated from the following files: