Qt 4.8
Public Functions | Properties | List of all members
QFileSystemIterator Class Reference

#include <qfilesystemiterator_p.h>

Public Functions

bool advance (QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
 
 QFileSystemIterator (const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters, QDirIterator::IteratorFlags flags=QDirIterator::FollowSymlinks|QDirIterator::Subdirectories)
 
 ~QFileSystemIterator ()
 

Properties

QFileSystemEntry::NativePath dirPath
 
HANDLE findFileHandle
 
QFileSystemEntry::NativePath nativePath
 
bool onlyDirs
 
bool uncFallback
 
int uncShareIndex
 
QStringList uncShares
 

Detailed Description

Definition at line 77 of file qfilesystemiterator_p.h.

Constructors and Destructors

◆ QFileSystemIterator()

QFileSystemIterator::QFileSystemIterator ( const QFileSystemEntry entry,
QDir::Filters  filters,
const QStringList nameFilters,
QDirIterator::IteratorFlags  flags = QDirIterator::FollowSymlinks | QDirIterator::Subdirectories 
)

Definition at line 52 of file qfilesystemiterator_unix.cpp.

54  : nativePath(entry.nativeFilePath())
55  , dir(0)
56  , dirEntry(0)
57 #if defined(Q_OS_QNX) && defined(__EXT_QNX__READDIR_R)
58  , direntSize(0)
59 #endif
60  , lastError(0)
61 {
63  Q_UNUSED(nameFilters)
64  Q_UNUSED(flags)
65 
66  if ((dir = QT_OPENDIR(nativePath.constData())) == 0) {
67  lastError = errno;
68  } else {
69 
70  if (!nativePath.endsWith('/'))
71  nativePath.append('/');
72 
73 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
74  // ### Race condition; we should use fpathconf and dirfd().
75  size_t maxPathName = ::pathconf(nativePath.constData(), _PC_NAME_MAX);
76  if (maxPathName == size_t(-1))
77  maxPathName = FILENAME_MAX;
78  maxPathName += sizeof(QT_DIRENT) + 1;
79 
80  QT_DIRENT *p = reinterpret_cast<QT_DIRENT*>(::malloc(maxPathName));
81  Q_CHECK_PTR(p);
82 
83  mt_file.reset(p);
84 #if defined(Q_OS_QNX) && defined(__EXT_QNX__READDIR_R)
85  direntSize = maxPathName;
86 
87  // Include extra stat information in the readdir() call (d_stat member of dirent_extra_stat).
88  // This is used in QFileSystemMetaData::fillFromDirEnt() to avoid extra stat() calls when iterating
89  // over directories
90  if (dircntl(dir, D_SETFLAG, D_FLAG_STAT) == -1)
91  lastError = errno;
92 #endif
93 #endif
94  }
95 }
QFileSystemEntry::NativePath nativePath
NativePath nativeFilePath() const
static const char *const filters[3]
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
QString & append(QChar c)
Definition: qstring.cpp:1777
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
#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
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712
int errno

◆ ~QFileSystemIterator()

QFileSystemIterator::~QFileSystemIterator ( )

Definition at line 97 of file qfilesystemiterator_unix.cpp.

98 {
99  if (dir)
100  QT_CLOSEDIR(dir);
101 }

Functions

◆ advance()

bool QFileSystemIterator::advance ( QFileSystemEntry fileEntry,
QFileSystemMetaData metaData 
)

Definition at line 103 of file qfilesystemiterator_unix.cpp.

Referenced by QFSFileEngineIterator::advance(), and QDirIteratorPrivate::advance().

104 {
105  if (!dir)
106  return false;
107 
108 #if defined(Q_OS_QNX) && defined(QT_EXT_QNX_READDIR_R)
109  lastError = QT_EXT_QNX_READDIR_R(dir, mt_file.data(), &dirEntry, direntSize);
110  if (lastError)
111  return false;
112 #elif defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
113  lastError = QT_READDIR_R(dir, mt_file.data(), &dirEntry);
114  if (lastError)
115  return false;
116 #else
117  // ### add local lock to prevent breaking reentrancy
118  dirEntry = QT_READDIR(dir);
119 #endif // _POSIX_THREAD_SAFE_FUNCTIONS
120 
121  if (dirEntry) {
122  fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath());
123  metaData.fillFromDirEnt(*dirEntry);
124  return true;
125  }
126 
127  lastError = errno;
128  return false;
129 }
QFileSystemEntry::NativePath nativePath
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void fillFromDirEnt(const QT_DIRENT &statBuffer)
int errno

Properties

◆ dirPath

QFileSystemEntry::NativePath QFileSystemIterator::dirPath
private

Definition at line 92 of file qfilesystemiterator_p.h.

◆ findFileHandle

HANDLE QFileSystemIterator::findFileHandle
private

Definition at line 93 of file qfilesystemiterator_p.h.

◆ nativePath

QFileSystemEntry::NativePath QFileSystemIterator::nativePath
private

Definition at line 88 of file qfilesystemiterator_p.h.

Referenced by advance(), and QFileSystemIterator().

◆ onlyDirs

bool QFileSystemIterator::onlyDirs
private

Definition at line 97 of file qfilesystemiterator_p.h.

◆ uncFallback

bool QFileSystemIterator::uncFallback
private

Definition at line 95 of file qfilesystemiterator_p.h.

◆ uncShareIndex

int QFileSystemIterator::uncShareIndex
private

Definition at line 96 of file qfilesystemiterator_p.h.

◆ uncShares

QStringList QFileSystemIterator::uncShares
private

Definition at line 94 of file qfilesystemiterator_p.h.


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