QDirListing: add ExcludeOther
Which is the same as ExcludeSpecial (the latter is new in 6.9). This is to match std::filesystem::is_other() which has a similar functionality. This makes it easier to remember/understand both APIs. Amends e583c3d5163a5512abac85e32359652e28a053f7. [ChangeLog][QtCore][QDirListing] Add IteratorFlag::ExcludeOther enumerator. IteratorFlag::ExcludeSpecial now becomes an, obsolete, alias for ExcludeOther (the name was changed to "other" to match the wording used in std::filesystem::is_other()). Change-Id: I986a2d822615f69ccf5ec283756ae063f5e18101 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
3caf64adda
commit
c553f39e3d
@ -75,15 +75,17 @@
|
|||||||
Don't list directories. When combined with ResolveSymlinks, symbolic
|
Don't list directories. When combined with ResolveSymlinks, symbolic
|
||||||
links to directories will be excluded too.
|
links to directories will be excluded too.
|
||||||
|
|
||||||
\value ExcludeSpecial
|
\omitvalue ExcludeSpecial
|
||||||
|
\value ExcludeOther
|
||||||
Don't list file system entries that are \e not directories, regular files,
|
Don't list file system entries that are \e not directories, regular files,
|
||||||
nor symbolic links.
|
or symbolic links.
|
||||||
\list
|
\list
|
||||||
\li On Unix, an example of a special file system entry is a FIFO, socket,
|
\li On Unix, a special (other) file system entry is a FIFO, socket,
|
||||||
character device, or block device. For more details on Linux, see the
|
character device, or block device. For more details see the
|
||||||
\l{https://www.man7.org/linux/man-pages/man2/mknod.2.html}{mknod manual page}.
|
\l{https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html}{\c mknod}
|
||||||
\li On Windows (for historical reasons) \c .lnk files are considered special
|
manual page.
|
||||||
file system entries.
|
\li On Windows (for historical reasons) \c .lnk files are considered
|
||||||
|
special (other) file system entries.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
\value ResolveSymlinks
|
\value ResolveSymlinks
|
||||||
@ -520,7 +522,7 @@ bool QDirListingPrivate::matchesFilters(QDirEntryInfo &entryInfo) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iteratorFlags.testAnyFlag(F::ExcludeSpecial)
|
if (iteratorFlags.testAnyFlag(F::ExcludeOther)
|
||||||
&& !entryInfo.isFile() && !entryInfo.isDir() && !entryInfo.isSymLink()) {
|
&& !entryInfo.isFile() && !entryInfo.isDir() && !entryInfo.isSymLink()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,11 @@ public:
|
|||||||
Default = 0x000000,
|
Default = 0x000000,
|
||||||
ExcludeFiles = 0x000004,
|
ExcludeFiles = 0x000004,
|
||||||
ExcludeDirs = 0x000008,
|
ExcludeDirs = 0x000008,
|
||||||
ExcludeSpecial = 0x000010,
|
QT6_ONLY(ExcludeSpecial = 0x000010,)
|
||||||
|
ExcludeOther = 0x000010,
|
||||||
ResolveSymlinks = 0x000020,
|
ResolveSymlinks = 0x000020,
|
||||||
FilesOnly = ExcludeDirs | ExcludeSpecial,
|
FilesOnly = ExcludeDirs | ExcludeOther,
|
||||||
DirsOnly = ExcludeFiles | ExcludeSpecial,
|
DirsOnly = ExcludeFiles | ExcludeOther,
|
||||||
IncludeHidden = 0x000040,
|
IncludeHidden = 0x000040,
|
||||||
IncludeDotAndDotDot = 0x000080,
|
IncludeDotAndDotDot = 0x000080,
|
||||||
CaseSensitive = 0x000100,
|
CaseSensitive = 0x000100,
|
||||||
|
@ -46,7 +46,7 @@ class QPollingFileSystemWatcherEngine : public QFileSystemWatcherEngine
|
|||||||
|
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
using F = QDirListing::IteratorFlag;
|
using F = QDirListing::IteratorFlag;
|
||||||
constexpr auto flags = F::ExcludeSpecial | F::IncludeDotAndDotDot;
|
constexpr auto flags = F::ExcludeOther | F::IncludeDotAndDotDot;
|
||||||
for (const auto &entry : QDirListing(fileInfo.absoluteFilePath(), flags))
|
for (const auto &entry : QDirListing(fileInfo.absoluteFilePath(), flags))
|
||||||
fileNames.emplace_back(entry.fileName());
|
fileNames.emplace_back(entry.fileName());
|
||||||
return fileNames;
|
return fileNames;
|
||||||
|
@ -620,7 +620,7 @@ void tst_QDirListing::recurseWithFilters() const
|
|||||||
expectedEntries.insert(QString::fromLatin1("recursiveDirs/dir1/textFileB.txt"));
|
expectedEntries.insert(QString::fromLatin1("recursiveDirs/dir1/textFileB.txt"));
|
||||||
expectedEntries.insert(QString::fromLatin1("recursiveDirs/textFileA.txt"));
|
expectedEntries.insert(QString::fromLatin1("recursiveDirs/textFileA.txt"));
|
||||||
|
|
||||||
constexpr auto flags = ItFlag::ExcludeDirs | ItFlag::ExcludeSpecial| ItFlag::Recursive;
|
constexpr auto flags = ItFlag::ExcludeDirs | ItFlag::ExcludeOther| ItFlag::Recursive;
|
||||||
for (const auto &dirEntry : QDirListing(u"recursiveDirs/"_s, QStringList{u"*.txt"_s}, flags))
|
for (const auto &dirEntry : QDirListing(u"recursiveDirs/"_s, QStringList{u"*.txt"_s}, flags))
|
||||||
actualEntries.insert(dirEntry.filePath());
|
actualEntries.insert(dirEntry.filePath());
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ void tst_QDirListing::longPath()
|
|||||||
dirName.append('x');
|
dirName.append('x');
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto flags = ItFlag::ExcludeFiles | ItFlag::ExcludeSpecial| ItFlag::Recursive;
|
constexpr auto flags = ItFlag::ExcludeFiles | ItFlag::ExcludeOther| ItFlag::Recursive;
|
||||||
QDirListing dirList(dir.absolutePath(), flags);
|
QDirListing dirList(dir.absolutePath(), flags);
|
||||||
qsizetype m = 0;
|
qsizetype m = 0;
|
||||||
for (auto it = dirList.begin(); it != dirList.end(); ++it)
|
for (auto it = dirList.begin(); it != dirList.end(); ++it)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user