summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-09-10 13:15:43 (GMT)
committerThomas Zander <t.zander@nokia.com>2010-09-10 13:15:43 (GMT)
commitcc23ac99d68af5c9bf537e5451b7ee7c7698e954 (patch)
treefe91ec2dd40894369ce0b76f9c74c2e140765486 /src/corelib/io
parent69b8cf630e9cc83cd678814bf88495c7fbb438f4 (diff)
downloadQt-cc23ac99d68af5c9bf537e5451b7ee7c7698e954.zip
Qt-cc23ac99d68af5c9bf537e5451b7ee7c7698e954.tar.gz
Qt-cc23ac99d68af5c9bf537e5451b7ee7c7698e954.tar.bz2
Move resolving of user/group name to the engine.
Reviewed-by: João Abecasis
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfileinfo.cpp25
-rw-r--r--src/corelib/io/qfilesystemengine.cpp16
-rw-r--r--src/corelib/io/qfilesystemengine_p.h4
-rw-r--r--src/corelib/io/qfilesystemengine_symbian.cpp12
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp12
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp12
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h13
7 files changed, 70 insertions, 24 deletions
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 68f1f55..d49ee74 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -101,10 +101,21 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const
QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const
{
- Q_ASSERT(fileEngine); // should never be called when using the native FS
if (cache_enabled && !fileOwners[(int)own].isNull())
return fileOwners[(int)own];
- QString ret = fileEngine->owner(own);
+ QString ret;
+ if (fileEngine == 0) {
+ switch (own) {
+ case QAbstractFileEngine::OwnerUser:
+ ret = QFileSystemEngine::resolveUserName(fileEntry, metaData);
+ break;
+ case QAbstractFileEngine::OwnerGroup:
+ ret = QFileSystemEngine::resolveGroupName(fileEntry, metaData);
+ break;
+ }
+ } else {
+ ret = fileEngine->owner(own);
+ }
if (ret.isNull())
ret = QLatin1String("");
if (cache_enabled)
@@ -1078,11 +1089,6 @@ QString QFileInfo::owner() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- if (d->fileEngine == 0) {
- if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserName))
- QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserName);
- return d->metaData.user();
- }
return d->getFileOwner(QAbstractFileEngine::OwnerUser);
}
@@ -1122,11 +1128,6 @@ QString QFileInfo::group() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- if (d->fileEngine == 0) {
- if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::GroupName))
- QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::GroupName);
- return d->metaData.group();
- }
return d->getFileOwner(QAbstractFileEngine::OwnerGroup);
}
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 56072d4..cbc4c42 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -287,4 +287,20 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
#endif
+//static
+QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData)
+{
+ if (!metaData.hasFlags(QFileSystemMetaData::UserId))
+ QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId);
+ return resolveGroupName(metaData.userId());
+}
+
+//static
+QString QFileSystemEngine::resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData)
+{
+ if (!metaData.hasFlags(QFileSystemMetaData::GroupId))
+ QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId);
+ return resolveGroupName(metaData.groupId());
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h
index 94fb4e5..94a8175 100644
--- a/src/corelib/io/qfilesystemengine_p.h
+++ b/src/corelib/io/qfilesystemengine_p.h
@@ -67,6 +67,10 @@ public:
static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data);
static QFileSystemEntry canonicalName(const QFileSystemEntry &entry);
static QFileSystemEntry absoluteName(const QFileSystemEntry &entry);
+ static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
+ static QString resolveUserName(uint userId);
+ static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
+ static QString resolveGroupName(uint groupId);
static QString bundleName(const QFileSystemEntry &entry);
diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp
index e725147..1ed4ee8 100644
--- a/src/corelib/io/qfilesystemengine_symbian.cpp
+++ b/src/corelib/io/qfilesystemengine_symbian.cpp
@@ -124,6 +124,18 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
}
//static
+QString QFileSystemEngine::resolveUserName(uint userId)
+{
+ return QString(); // TODO
+}
+
+//static
+QString QFileSystemEngine::resolveGroupName(uint groupId)
+{
+ return QString(); // TODO
+}
+
+//static
QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
{
Q_UNUSED(entry);
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index eb6b9f1..fdb881f 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -267,6 +267,18 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
}
//static
+QString QFileSystemEngine::resolveUserName(uint userId)
+{
+ return QString(); // TODO
+}
+
+//static
+QString QFileSystemEngine::resolveGroupName(uint groupId)
+{
+ return QString(); // TODO
+}
+
+//static
QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
{
#if !defined(QWS) && defined(Q_OS_MAC)
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 8572506..28d5db4 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -67,6 +67,18 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
}
//static
+QString QFileSystemEngine::resolveUserName(uint userId)
+{
+ return QString(); // TODO
+}
+
+//static
+QString QFileSystemEngine::resolveGroupName(uint groupId)
+{
+ return QString(); // TODO
+}
+
+//static
QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
{
return QString();
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index f7bc863..ec25a0b 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -137,9 +137,6 @@ public:
OwnerIds = UserId | GroupId,
- UserName = 0x40000000,
- GroupName = 0x80000000,
-
PosixStatFlags = QFileSystemMetaData::OtherPermissions
| QFileSystemMetaData::GroupPermissions
| QFileSystemMetaData::OwnerPermissions
@@ -204,8 +201,6 @@ public:
QDateTime fileTime(QAbstractFileEngine::FileTime time) const;
uint userId() const;
uint groupId() const;
- QString user() const;
- QString group() const;
uint ownerId(QAbstractFileEngine::FileOwner owner) const;
#ifdef Q_OS_UNIX
@@ -256,8 +251,7 @@ inline QDateTime QFileSystemMetaData::accessTime() const { return QDa
inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime time) const
{
- switch (time)
- {
+ switch (time) {
case QAbstractFileEngine::ModificationTime:
return modificationTime();
@@ -274,9 +268,6 @@ inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime tim
inline uint QFileSystemMetaData::userId() const { return userId_; }
inline uint QFileSystemMetaData::groupId() const { return groupId_; }
-inline QString QFileSystemMetaData::user() const { return QString(); /* TODO */ }
-inline QString QFileSystemMetaData::group() const { return QString(); /* TODO */ }
-
inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const
{
if (owner == QAbstractFileEngine::OwnerUser)
@@ -298,8 +289,6 @@ inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime tim
}
inline uint QFileSystemMetaData::userId() const { return (uint) -2; }
inline uint QFileSystemMetaData::groupId() const { return (uint) -2; }
-inline QString QFileSystemMetaData::user() const { return QString(); }
-inline QString QFileSystemMetaData::group() const { return QString(); }
inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const
{
Q_UNUSED(owner);