summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qdir.cpp46
-rw-r--r--src/corelib/io/qdiriterator.cpp2
2 files changed, 24 insertions, 24 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index bae47bfb2b..eb9cb99910 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -91,13 +91,13 @@ enum {
};
// Return the length of the root part of an absolute path, for use by cleanPath(), cd().
-static int rootLength(const QString &name, bool allowUncPaths)
+static qsizetype rootLength(QStringView name, bool allowUncPaths)
{
- const int len = name.length();
+ const qsizetype len = name.size();
// starts with double slash
if (allowUncPaths && name.startsWith(QLatin1String("//"))) {
// Server name '//server/path' is part of the prefix.
- const int nextSlash = name.indexOf(QLatin1Char('/'), 2);
+ const qsizetype nextSlash = name.indexOf(u'/', 2);
return nextSlash >= 0 ? nextSlash + 1 : len;
}
#if defined(Q_OS_WIN)
@@ -166,7 +166,7 @@ bool QDirPrivate::exists() const
inline QChar QDirPrivate::getFilterSepChar(const QString &nameFilter)
{
QChar sep(QLatin1Char(';'));
- int i = nameFilter.indexOf(sep, 0);
+ qsizetype i = nameFilter.indexOf(sep, 0);
if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1)
sep = QChar(QLatin1Char(' '));
return sep;
@@ -322,7 +322,7 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l,
QStringList *names, QFileInfoList *infos)
{
// names and infos are always empty lists or 0 here
- int n = l.size();
+ qsizetype n = l.size();
if (n > 0) {
if (n == 1 || (sort & QDir::SortByMask) == QDir::Unsorted) {
if (infos)
@@ -333,16 +333,16 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l,
}
} else {
QScopedArrayPointer<QDirSortItem> si(new QDirSortItem[n]);
- for (int i = 0; i < n; ++i)
+ for (qsizetype i = 0; i < n; ++i)
si[i].item = l.at(i);
std::sort(si.data(), si.data() + n, QDirSortItemComparator(sort));
// put them back in the list(s)
if (infos) {
- for (int i = 0; i < n; ++i)
+ for (qsizetype i = 0; i < n; ++i)
infos->append(si[i].item);
}
if (names) {
- for (int i = 0; i < n; ++i)
+ for (qsizetype i = 0; i < n; ++i)
names->append(si[i].item.fileName());
}
}
@@ -709,11 +709,11 @@ QString QDir::dirName() const
#ifdef Q_OS_WIN
-static int drivePrefixLength(const QString &path)
+static qsizetype drivePrefixLength(QStringView path)
{
// Used to extract path's drive for use as prefix for an "absolute except for drive" path
- const int size = path.length();
- int drive = 2; // length of drive prefix
+ const qsizetype size = path.size();
+ qsizetype drive = 2; // length of drive prefix
if (size > 1 && path.at(1).unicode() == ':') {
if (Q_UNLIKELY(!path.at(0).isLetter()))
return 0;
@@ -725,7 +725,7 @@ static int drivePrefixLength(const QString &path)
drive++;
if (drive >= size) {
qWarning("Base directory starts with neither a drive nor a UNC share: %s",
- qUtf8Printable(QDir::toNativeSeparators(path)));
+ qUtf8Printable(QDir::toNativeSeparators(path.toString())));
return 0;
}
while (drive < size && path.at(drive).unicode() != '/')
@@ -775,7 +775,7 @@ QString QDir::filePath(const QString &fileName) const
#ifdef Q_OS_WIN
if (fileName.startsWith(QLatin1Char('/')) || fileName.startsWith(QLatin1Char('\\'))) {
// Handle the "absolute except for drive" case (i.e. \blah not c:\blah):
- const int drive = drivePrefixLength(ret);
+ const qsizetype drive = drivePrefixLength(ret);
return drive > 0 ? QStringView{ret}.left(drive) % fileName : fileName;
}
#endif // Q_OS_WIN
@@ -807,7 +807,7 @@ QString QDir::absoluteFilePath(const QString &fileName) const
// Handle the "absolute except for drive" case (i.e. \blah not c:\blah):
if (fileName.startsWith(QLatin1Char('/')) || fileName.startsWith(QLatin1Char('\\'))) {
// Combine absoluteDirPath's drive with fileName
- const int drive = drivePrefixLength(absoluteDirPath);
+ const qsizetype drive = drivePrefixLength(absoluteDirPath);
if (Q_LIKELY(drive))
return QStringView{absoluteDirPath}.left(drive) % fileName;
@@ -916,7 +916,7 @@ QString QDir::relativeFilePath(const QString &fileName) const
QString QDir::toNativeSeparators(const QString &pathName)
{
#if defined(Q_OS_WIN)
- int i = pathName.indexOf(QLatin1Char('/'));
+ qsizetype i = pathName.indexOf(u'/');
if (i != -1) {
QString n(pathName);
@@ -2160,7 +2160,7 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
{
const bool allowUncPaths = flags.testAnyFlag(QDirPrivate::AllowUncPaths);
const bool isRemote = flags.testAnyFlag(QDirPrivate::RemotePath);
- const int len = name.length();
+ const qsizetype len = name.size();
if (ok)
*ok = false;
@@ -2168,15 +2168,15 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
if (len == 0)
return name;
- int i = len - 1;
+ qsizetype i = len - 1;
QVarLengthArray<char16_t> outVector(len);
- int used = len;
+ qsizetype used = len;
char16_t *out = outVector.data();
const ushort *p = name.utf16();
const ushort *prefix = p;
- int up = 0;
+ qsizetype up = 0;
- const int prefixLength = rootLength(name, allowUncPaths);
+ const qsizetype prefixLength = rootLength(name, allowUncPaths);
p += prefixLength;
i -= prefixLength;
@@ -2187,10 +2187,10 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
--i;
}
- auto isDot = [](const ushort *p, int i) {
+ auto isDot = [](const ushort *p, qsizetype i) {
return i > 1 && p[i - 1] == '.' && p[i - 2] == '/';
};
- auto isDotDot = [](const ushort *p, int i) {
+ auto isDotDot = [](const ushort *p, qsizetype i) {
return i > 2 && p[i - 1] == '.' && p[i - 2] == '.' && p[i - 3] == '/';
};
@@ -2293,7 +2293,7 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
// string only consists of a prefix followed by one or more slashes. Just skip the slash.
++used;
}
- for (int i = prefixLength - 1; i >= 0; --i)
+ for (qsizetype i = prefixLength - 1; i >= 0; --i)
out[--used] = prefix[i];
} else {
if (isEmpty) {
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 7e86aacdb1..ed570f5d48 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -328,7 +328,7 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
return false;
// filter . and ..?
- const int fileNameSize = fileName.size();
+ const qsizetype fileNameSize = fileName.size();
const bool dotOrDotDot = fileName[0] == QLatin1Char('.')
&& ((fileNameSize == 1)
||(fileNameSize == 2 && fileName[1] == QLatin1Char('.')));