summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfsfileengine_unix.cpp
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-09-23 16:10:46 +0200
committerThomas Zander <t.zander@nokia.com>2010-09-23 17:32:47 +0200
commit2645784f05db7b1e631621c511e94c88fc5cd211 (patch)
tree7fb8c25792da90509fc020ddb49b9f227dcaf2c8 /src/corelib/io/qfsfileengine_unix.cpp
parent59491b5cb9c7dc54f701ba19185fede58a7355db (diff)
Move resolving names to qfilesystemengine
Resolve username and group names code is now in the QFileSystemEngine Reviewed-by: João Abecasis
Diffstat (limited to 'src/corelib/io/qfsfileengine_unix.cpp')
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp47
1 files changed, 3 insertions, 44 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 7b7cd7fb6a..0845cb3937 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -892,50 +892,9 @@ uint QFSFileEngine::ownerId(FileOwner own) const
QString QFSFileEngine::owner(FileOwner own) const
{
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
- int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
- if (size_max == -1)
- size_max = 1024;
- QVarLengthArray<char, 1024> buf(size_max);
-#endif
-
- if (own == OwnerUser) {
- struct passwd *pw = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
- struct passwd entry;
- getpwuid_r(ownerId(own), &entry, buf.data(), buf.size(), &pw);
-#else
- pw = getpwuid(ownerId(own));
-#endif
- if (pw)
- return QFile::decodeName(QByteArray(pw->pw_name));
- } else if (own == OwnerGroup) {
-#if !defined(Q_OS_SYMBIAN)
- struct group *gr = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
- size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
- if (size_max == -1)
- size_max = 1024;
- buf.resize(size_max);
- struct group entry;
- // Some large systems have more members than the POSIX max size
- // Loop over by doubling the buffer size (upper limit 250k)
- for (unsigned size = size_max; size < 256000; size += size)
- {
- buf.resize(size);
- // ERANGE indicates that the buffer was too small
- if (!getgrgid_r(ownerId(own), &entry, buf.data(), buf.size(), &gr)
- || errno != ERANGE)
- break;
- }
-#else
- gr = getgrgid(ownerId(own));
-#endif
- if (gr)
- return QFile::decodeName(QByteArray(gr->gr_name));
-#endif
- }
- return QString();
+ if (own == OwnerUser)
+ return QFileSystemEngine::resolveUserName(ownerId(own));
+ return QFileSystemEngine::resolveGroupName(ownerId(own));
}
bool QFSFileEngine::setPermissions(uint perms)