diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-07-04 11:39:07 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-08-08 21:48:23 +0000 |
commit | 6504bc6bbc9276fe1a26c1af53c202371f334416 (patch) | |
tree | 4ec3c60760a261662ed8f43e97e12ad9b7241ca2 /src/corelib/io/qfilesystemengine.cpp | |
parent | d3393ce25833c0afd7f0fa6b85fd6f3bd7ad520a (diff) |
QFileInfo: harmonize QFileInfo() and QFileInfo("")
If a QFileInfo was constructed with an empty path, which could happen
with QFileInfo(QFile()) or via QDir, etc., then it would issue system
calls to empty paths and could even produce warnings. This commit makes
am empty path name be the same as a default-constructed QFileInfo and
corrects the use if 0 for ownerId and groupId to match the
documentation.
[ChangeLog][Important Behavior Changes] QFileInfo on empty strings now
behaves like the default-constructed QFileInfo. Notably, path() will now
be the empty string too, instead of ".", which means absoluteFilePath()
is no longer the current working directory.
Change-Id: I8d96dea9955d4c749b99fffd14ce34968b1d9bbf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/io/qfilesystemengine.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 955b459bba..73a2e37a38 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -213,6 +213,8 @@ QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileS #else //(Q_OS_UNIX) if (!metaData.hasFlags(QFileSystemMetaData::UserId)) QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId); + if (!metaData.exists()) + return QString(); return resolveUserName(metaData.userId()); #endif } @@ -226,6 +228,8 @@ QString QFileSystemEngine::resolveGroupName(const QFileSystemEntry &entry, QFile #else //(Q_OS_UNIX) if (!metaData.hasFlags(QFileSystemMetaData::GroupId)) QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId); + if (!metaData.exists()) + return QString(); return resolveGroupName(metaData.groupId()); #endif } |