Qt 4.8
Public Types | Public Functions | Properties | Friends | List of all members
QFileSystemMetaData Class Reference

#include <qfilesystemmetadata_p.h>

Public Types

enum  MetaDataFlag {
  OtherReadPermission = 0x00000004, OtherWritePermission = 0x00000002, OtherExecutePermission = 0x00000001, GroupReadPermission = 0x00000040,
  GroupWritePermission = 0x00000020, GroupExecutePermission = 0x00000010, UserReadPermission = 0x00000400, UserWritePermission = 0x00000200,
  UserExecutePermission = 0x00000100, OwnerReadPermission = 0x00004000, OwnerWritePermission = 0x00002000, OwnerExecutePermission = 0x00001000,
  OtherPermissions = OtherReadPermission | OtherWritePermission | OtherExecutePermission, GroupPermissions = GroupReadPermission | GroupWritePermission | GroupExecutePermission, UserPermissions = UserReadPermission | UserWritePermission | UserExecutePermission, OwnerPermissions = OwnerReadPermission | OwnerWritePermission | OwnerExecutePermission,
  ReadPermissions = OtherReadPermission | GroupReadPermission | UserReadPermission | OwnerReadPermission, WritePermissions = OtherWritePermission | GroupWritePermission | UserWritePermission | OwnerWritePermission, ExecutePermissions = OtherExecutePermission | GroupExecutePermission | UserExecutePermission | OwnerExecutePermission, Permissions = OtherPermissions | GroupPermissions | UserPermissions | OwnerPermissions,
  LinkType = 0x00010000, FileType = 0x00020000, DirectoryType = 0x00040000, BundleType = 0x00080000,
  AliasType = 0x08000000, WinLnkType = 0x08000000, SequentialType = 0x00800000, LegacyLinkType = LinkType | AliasType | WinLnkType,
  Type = LinkType | FileType | DirectoryType | BundleType | SequentialType | AliasType, HiddenAttribute = 0x00100000, SizeAttribute = 0x00200000, ExistsAttribute = 0x00400000,
  Attributes = HiddenAttribute | SizeAttribute | ExistsAttribute, CreationTime = 0x01000000, ModificationTime = 0x02000000, AccessTime = 0x04000000,
  Times = CreationTime | ModificationTime | AccessTime, UserId = 0x10000000, GroupId = 0x20000000, OwnerIds = UserId | GroupId,
  PosixStatFlags, SymbianTEntryFlags, WinStatFlags, AllMetaDataFlags = 0xFFFFFFFF
}
 

Public Functions

QDateTime accessTime () const
 
void clear ()
 
void clearFlags (MetaDataFlags flags=AllMetaDataFlags)
 
QDateTime creationTime () const
 
bool exists () const
 
QDateTime fileTime (QAbstractFileEngine::FileTime time) const
 
void fillFromDirEnt (const QT_DIRENT &statBuffer)
 
void fillFromFileAttribute (DWORD fileAttribute, bool isDriveRoot=false)
 
void fillFromFindData (WIN32_FIND_DATA &findData, bool setLinkType=false, bool isDriveRoot=false)
 
void fillFromFindInfo (BY_HANDLE_FILE_INFORMATION &fileInfo)
 
void fillFromStatBuf (const QT_STATBUF &statBuffer)
 
uint groupId () const
 
bool hasFlags (MetaDataFlags flags) const
 
bool isAlias () const
 
bool isBundle () const
 
bool isDirectory () const
 
bool isFile () const
 
bool isHidden () const
 
bool isLegacyLink () const
 
bool isLink () const
 
bool isLnkFile () const
 
bool isSequential () const
 
MetaDataFlags missingFlags (MetaDataFlags flags)
 
QDateTime modificationTime () const
 
uint ownerId (QAbstractFileEngine::FileOwner owner) const
 
QFile::Permissions permissions () const
 
 QFileSystemMetaData ()
 
qint64 size () const
 
uint userId () const
 

Properties

FILETIME creationTime_
 
MetaDataFlags entryFlags
 
DWORD fileAttribute_
 
MetaDataFlags knownFlagsMask
 
FILETIME lastAccessTime_
 
FILETIME lastWriteTime_
 
qint64 size_
 

Friends

class QFileSystemEngine
 

Detailed Description

Definition at line 75 of file qfilesystemmetadata_p.h.

Enumerations

◆ MetaDataFlag

Enumerator
OtherReadPermission 
OtherWritePermission 
OtherExecutePermission 
GroupReadPermission 
GroupWritePermission 
GroupExecutePermission 
UserReadPermission 
UserWritePermission 
UserExecutePermission 
OwnerReadPermission 
OwnerWritePermission 
OwnerExecutePermission 
OtherPermissions 
GroupPermissions 
UserPermissions 
OwnerPermissions 
ReadPermissions 
WritePermissions 
ExecutePermissions 
Permissions 
LinkType 
FileType 
DirectoryType 
BundleType 
AliasType 
WinLnkType 
SequentialType 
LegacyLinkType 
Type 
HiddenAttribute 
SizeAttribute 
ExistsAttribute 
Attributes 
CreationTime 
ModificationTime 
AccessTime 
Times 
UserId 
GroupId 
OwnerIds 
PosixStatFlags 
SymbianTEntryFlags 
WinStatFlags 
AllMetaDataFlags 

Definition at line 83 of file qfilesystemmetadata_p.h.

83  {
84  // Permissions, overlaps with QFile::Permissions
85  OtherReadPermission = 0x00000004, OtherWritePermission = 0x00000002, OtherExecutePermission = 0x00000001,
86  GroupReadPermission = 0x00000040, GroupWritePermission = 0x00000020, GroupExecutePermission = 0x00000010,
87  UserReadPermission = 0x00000400, UserWritePermission = 0x00000200, UserExecutePermission = 0x00000100,
88  OwnerReadPermission = 0x00004000, OwnerWritePermission = 0x00002000, OwnerExecutePermission = 0x00001000,
89 
94 
98 
99  Permissions = OtherPermissions | GroupPermissions | UserPermissions | OwnerPermissions,
100 
101  // Type
102 #ifdef Q_OS_SYMBIAN
103  LinkType = 0,
104 #else
105  LinkType = 0x00010000,
106 #endif
107  FileType = 0x00020000,
108  DirectoryType = 0x00040000,
109 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
110  BundleType = 0x00080000,
111  AliasType = 0x08000000,
112 #else
113  BundleType = 0x0,
114  AliasType = 0x0,
115 #endif
116 #if defined(Q_OS_WIN)
117  WinLnkType = 0x08000000, // Note: Uses the same position for AliasType on Mac
118 #else
119  WinLnkType = 0x0,
120 #endif
121  SequentialType = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag
122 
123  LegacyLinkType = LinkType | AliasType | WinLnkType,
124 
126 
127  // Attributes
128  HiddenAttribute = 0x00100000,
129  SizeAttribute = 0x00200000, // Note: overlaps with QAbstractFileEngine::LocalDiskFlag
130  ExistsAttribute = 0x00400000,
131 
132  Attributes = HiddenAttribute | SizeAttribute | ExistsAttribute,
133 
134  // Times
135  CreationTime = 0x01000000, // Note: overlaps with QAbstractFileEngine::Refresh
136  ModificationTime = 0x02000000,
137  AccessTime = 0x04000000,
138 
139  Times = CreationTime | ModificationTime | AccessTime,
140 
141  // Owner IDs
142  UserId = 0x10000000,
143  GroupId = 0x20000000,
144 
145  OwnerIds = UserId | GroupId,
146 
156 
163 #if defined(Q_OS_WIN)
170 #endif
171 
172  AllMetaDataFlags = 0xFFFFFFFF
173 
174  };

Constructors and Destructors

◆ QFileSystemMetaData()

QFileSystemMetaData::QFileSystemMetaData ( )
inline

Definition at line 78 of file qfilesystemmetadata_p.h.

79  : knownFlagsMask(0)
80  {
81  }

Functions

◆ accessTime()

QDateTime QFileSystemMetaData::accessTime ( ) const
inline

Definition at line 1249 of file qfilesystemengine_win.cpp.

Referenced by fileTime(), ownerId(), and permissions().

1250 {
1252 }
static QDateTime fileTimeToQDateTime(const FILETIME *time)

◆ clear()

void QFileSystemMetaData::clear ( )
inline

◆ clearFlags()

void QFileSystemMetaData::clearFlags ( MetaDataFlags  flags = AllMetaDataFlags)
inline

Definition at line 192 of file qfilesystemmetadata_p.h.

Referenced by QFSFileEnginePrivate::longFileName(), and openModeToFopenMode().

193  {
194  knownFlagsMask &= ~flags;
195  }

◆ creationTime()

QDateTime QFileSystemMetaData::creationTime ( ) const
inline

Definition at line 1241 of file qfilesystemengine_win.cpp.

Referenced by fileTime(), ownerId(), and permissions().

1242 {
1244 }
static QDateTime fileTimeToQDateTime(const FILETIME *time)

◆ exists()

bool QFileSystemMetaData::exists ( ) const
inline

◆ fileTime()

QDateTime QFileSystemMetaData::fileTime ( QAbstractFileEngine::FileTime  time) const
inline

Definition at line 278 of file qfilesystemmetadata_p.h.

Referenced by ownerId(), and permissions().

279 {
280  switch (time) {
282  return modificationTime();
283 
285  return accessTime();
286 
288  return creationTime();
289  }
290 
291  return QDateTime();
292 }
QDateTime modificationTime() const
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
QDateTime creationTime() const

◆ fillFromDirEnt()

void QFileSystemMetaData::fillFromDirEnt ( const QT_DIRENT &  statBuffer)

Definition at line 309 of file qfilesystemengine.cpp.

Referenced by QFileSystemIterator::advance(), and permissions().

310 {
311 #if defined(Q_OS_QNX)
312  entryFlags = 0;
313  knownFlagsMask = 0;
314  for (dirent_extra *extra = _DEXTRA_FIRST(&entry); _DEXTRA_VALID(extra, &entry);
315  extra = _DEXTRA_NEXT(extra)) {
316  if (extra->d_type == _DTYPE_STAT || extra->d_type == _DTYPE_LSTAT) {
317 
318  const struct dirent_extra_stat * const extra_stat =
319  reinterpret_cast<struct dirent_extra_stat *>(extra);
320 
321  // Remember whether this was a link or not, this saves an lstat() call later.
322  if (extra->d_type == _DTYPE_LSTAT) {
324  if (S_ISLNK(extra_stat->d_stat.st_mode))
326  }
327 
328  // For symlinks, the extra type _DTYPE_LSTAT doesn't work for filling out the meta data,
329  // as we need the stat() information there, not the lstat() information.
330  // In this case, don't use the extra information.
331  // Unfortunately, readdir() never seems to return extra info of type _DTYPE_STAT, so for
332  // symlinks, we always incur the cost of an extra stat() call later.
333  if (S_ISLNK(extra_stat->d_stat.st_mode) && extra->d_type == _DTYPE_LSTAT)
334  continue;
335 
336 #if defined(QT_USE_XOPEN_LFS_EXTENSIONS) && defined(QT_LARGEFILE_SUPPORT)
337  // Even with large file support, d_stat is always of type struct stat, not struct stat64,
338  // so it needs to be converted
339  struct stat64 statBuf;
340  fillStat64fromStat32(&statBuf, extra_stat->d_stat);
341  fillFromStatBuf(statBuf);
342 #else
343  fillFromStatBuf(extra_stat->d_stat);
344 #endif
346  if (!S_ISLNK(extra_stat->d_stat.st_mode)) {
349  }
350  }
351  }
352 #elif defined(_DIRENT_HAVE_D_TYPE) || defined(Q_OS_BSD4) || defined(Q_OS_SYMBIAN)
353  // BSD4 includes Mac OS X
354 
355  // ### This will clear all entry flags and knownFlagsMask
356  switch (entry.d_type)
357  {
358  case DT_DIR:
364 
367 
368  break;
369 
370  case DT_BLK:
371  case DT_CHR:
372  case DT_FIFO:
373  case DT_SOCK:
374  // ### System attribute
382 
385 
386  break;
387 
388  case DT_LNK:
391  break;
392 
393  case DT_REG:
400 
403 
404  break;
405 
406  case DT_UNKNOWN:
407  default:
408  clear();
409  }
410 #else
411  Q_UNUSED(entry)
412 #endif
413 }
#define S_ISLNK(x)
Definition: qzip.cpp:69
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void fillFromStatBuf(const QT_STATBUF &statBuffer)

◆ fillFromFileAttribute()

void QFileSystemMetaData::fillFromFileAttribute ( DWORD  fileAttribute,
bool  isDriveRoot = false 
)
inline

Definition at line 342 of file qfilesystemmetadata_p.h.

Referenced by fillFromFindData(), fillFromFindInfo(), permissions(), and tryDriveUNCFallback().

343 {
344  fileAttribute_ = fileAttribute;
345  // Ignore the hidden attribute for drives.
346  if (!isDriveRoot && (fileAttribute_ & FILE_ATTRIBUTE_HIDDEN))
348  entryFlags |= ((fileAttribute & FILE_ATTRIBUTE_DIRECTORY) ? DirectoryType: FileType);
351 }

◆ fillFromFindData()

void QFileSystemMetaData::fillFromFindData ( WIN32_FIND_DATA &  findData,
bool  setLinkType = false,
bool  isDriveRoot = false 
)
inline

Definition at line 353 of file qfilesystemmetadata_p.h.

Referenced by QFileSystemEngine::fillMetaData(), permissions(), and tryFindFallback().

354 {
355  fillFromFileAttribute(findData.dwFileAttributes, isDriveRoot);
356  creationTime_ = findData.ftCreationTime;
357  lastAccessTime_ = findData.ftLastAccessTime;
358  lastWriteTime_ = findData.ftLastWriteTime;
359  if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) {
360  size_ = 0;
361  } else {
362  size_ = findData.nFileSizeHigh;
363  size_ <<= 32;
364  size_ += findData.nFileSizeLow;
365  }
367  if (setLinkType) {
369  entryFlags &= ~LinkType;
370 #if !defined(Q_OS_WINCE)
371  if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT)
372  && findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
373  entryFlags |= LinkType;
374  }
375 #endif
376 
377  }
378 }
void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot=false)
#define IO_REPARSE_TAG_SYMLINK

◆ fillFromFindInfo()

void QFileSystemMetaData::fillFromFindInfo ( BY_HANDLE_FILE_INFORMATION &  fileInfo)
inline

Definition at line 380 of file qfilesystemmetadata_p.h.

Referenced by QFileSystemEngine::fillMetaData(), and permissions().

381 {
382  fillFromFileAttribute(fileInfo.dwFileAttributes);
383  creationTime_ = fileInfo.ftCreationTime;
384  lastAccessTime_ = fileInfo.ftLastAccessTime;
385  lastWriteTime_ = fileInfo.ftLastWriteTime;
386  if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) {
387  size_ = 0;
388  } else {
389  size_ = fileInfo.nFileSizeHigh;
390  size_ <<= 32;
391  size_ += fileInfo.nFileSizeLow;
392  }
394 }
void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot=false)

◆ fillFromStatBuf()

void QFileSystemMetaData::fillFromStatBuf ( const QT_STATBUF &  statBuffer)

Definition at line 254 of file qfilesystemengine.cpp.

Referenced by QFileSystemEngine::fillMetaData(), and permissions().

255 {
256  // Permissions
257  if (statBuffer.st_mode & S_IRUSR)
259  if (statBuffer.st_mode & S_IWUSR)
261  if (statBuffer.st_mode & S_IXUSR)
263 
264  if (statBuffer.st_mode & S_IRGRP)
266  if (statBuffer.st_mode & S_IWGRP)
268  if (statBuffer.st_mode & S_IXGRP)
270 
271  if (statBuffer.st_mode & S_IROTH)
273  if (statBuffer.st_mode & S_IWOTH)
275  if (statBuffer.st_mode & S_IXOTH)
277 
278  // Type
279  if ((statBuffer.st_mode & S_IFMT) == S_IFREG)
281  else if ((statBuffer.st_mode & S_IFMT) == S_IFDIR)
283  else
285 
286  // Attributes
288  size_ = statBuffer.st_size;
289 #if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) \
290  && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
291  if (statBuffer.st_flags & UF_HIDDEN) {
294  }
295 #endif
296 
297  // Times
298 #ifdef Q_OS_SYMBIAN
299  modificationTime_ = qt_symbian_time_t_To_TTime(statBuffer.st_mtime);
300 #else
301  creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime;
302  modificationTime_ = statBuffer.st_mtime;
303  accessTime_ = statBuffer.st_atime;
304  userId_ = statBuffer.st_uid;
305  groupId_ = statBuffer.st_gid;
306 #endif
307 }
#define S_IFREG
#define S_IWOTH
Definition: qzip.cpp:83
#define S_IRGRP
Definition: qzip.cpp:79
#define S_IXGRP
Definition: qzip.cpp:81
#define S_IRUSR
Definition: qzip.cpp:71
#define S_IXUSR
Definition: qzip.cpp:77
#define S_IFMT
#define S_IXOTH
Definition: qzip.cpp:84
#define S_IROTH
Definition: qzip.cpp:82
#define S_IFDIR
#define S_IWGRP
Definition: qzip.cpp:80
#define S_IWUSR
Definition: qzip.cpp:74

◆ groupId()

uint QFileSystemMetaData::groupId ( ) const
inline

Definition at line 301 of file qfilesystemmetadata_p.h.

Referenced by ownerId(), permissions(), and QFileSystemEngine::resolveGroupName().

301 { return groupId_; }

◆ hasFlags()

bool QFileSystemMetaData::hasFlags ( MetaDataFlags  flags) const
inline

◆ isAlias()

bool QFileSystemMetaData::isAlias ( ) const
inline

Definition at line 271 of file qfilesystemmetadata_p.h.

Referenced by isDirectory().

◆ isBundle()

bool QFileSystemMetaData::isBundle ( ) const
inline

Definition at line 270 of file qfilesystemmetadata_p.h.

Referenced by isAlias(), and isDirectory().

◆ isDirectory()

bool QFileSystemMetaData::isDirectory ( ) const
inline

◆ isFile()

bool QFileSystemMetaData::isFile ( ) const
inline

◆ isHidden()

bool QFileSystemMetaData::isHidden ( ) const
inline

◆ isLegacyLink()

bool QFileSystemMetaData::isLegacyLink ( ) const
inline

◆ isLink()

bool QFileSystemMetaData::isLink ( ) const
inline

◆ isLnkFile()

bool QFileSystemMetaData::isLnkFile ( ) const
inline

◆ isSequential()

bool QFileSystemMetaData::isSequential ( ) const
inline

◆ missingFlags()

MetaDataFlags QFileSystemMetaData::missingFlags ( MetaDataFlags  flags)
inline

◆ modificationTime()

QDateTime QFileSystemMetaData::modificationTime ( ) const
inline

Definition at line 1245 of file qfilesystemengine_win.cpp.

Referenced by fileTime(), ownerId(), and permissions().

1246 {
1248 }
static QDateTime fileTimeToQDateTime(const FILETIME *time)

◆ ownerId()

uint QFileSystemMetaData::ownerId ( QAbstractFileEngine::FileOwner  owner) const
inline

Definition at line 303 of file qfilesystemmetadata_p.h.

Referenced by permissions().

304 {
306  return userId();
307  else
308  return groupId();
309 }
static QWidget * owner

◆ permissions()

QFile::Permissions QFileSystemMetaData::permissions ( ) const
inline

Definition at line 215 of file qfilesystemmetadata_p.h.

Referenced by QDir::isReadable().

◆ size()

qint64 QFileSystemMetaData::size ( ) const
inline

◆ userId()

uint QFileSystemMetaData::userId ( ) const
inline

Definition at line 300 of file qfilesystemmetadata_p.h.

Referenced by ownerId(), permissions(), and QFileSystemEngine::resolveUserName().

300 { return userId_; }

Friends and Related Functions

◆ QFileSystemEngine

friend class QFileSystemEngine
friend

Definition at line 241 of file qfilesystemmetadata_p.h.

Properties

◆ creationTime_

FILETIME QFileSystemMetaData::creationTime_
private

◆ entryFlags

MetaDataFlags QFileSystemMetaData::entryFlags
private

◆ fileAttribute_

DWORD QFileSystemMetaData::fileAttribute_
private

◆ knownFlagsMask

MetaDataFlags QFileSystemMetaData::knownFlagsMask
private

◆ lastAccessTime_

FILETIME QFileSystemMetaData::lastAccessTime_
private

◆ lastWriteTime_

FILETIME QFileSystemMetaData::lastWriteTime_
private

◆ size_

qint64 QFileSystemMetaData::size_
private

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