diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2010-03-09 13:57:21 (GMT) |
---|---|---|
committer | João Abecasis <joao@trolltech.com> | 2010-03-09 15:46:29 (GMT) |
commit | 9b6c5a82b3693068e2db321c30be8c2e5f43b680 (patch) | |
tree | 71f2396fd608cff51e1e7bd539556fa6e1ededbe /src | |
parent | cd842fd1648e58b1c9359e0a88a2a166b3b0905c (diff) | |
download | Qt-9b6c5a82b3693068e2db321c30be8c2e5f43b680.zip Qt-9b6c5a82b3693068e2db321c30be8c2e5f43b680.tar.gz Qt-9b6c5a82b3693068e2db321c30be8c2e5f43b680.tar.bz2 |
move permissions calculation code to separate method
Merge-request: 428
Reviewed-by: João Abecasis <joao@trolltech.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfsfileengine_p.h | 2 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 63 |
2 files changed, 37 insertions, 28 deletions
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 0f63eb8..c540173 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -156,9 +156,7 @@ protected: void init(); -#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) QAbstractFileEngine::FileFlags getPermissions() const; -#endif }; QT_END_NAMESPACE diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 1331f54..8841fea 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -737,6 +737,41 @@ static bool _q_isMacHidden(const QString &path) #endif /*! + \internal +*/ +QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions() const +{ + QAbstractFileEngine::FileFlags ret = 0; + + if (st.st_mode & S_IRUSR) + ret |= QAbstractFileEngine::ReadOwnerPerm; + if (st.st_mode & S_IWUSR) + ret |= QAbstractFileEngine::WriteOwnerPerm; + if (st.st_mode & S_IXUSR) + ret |= QAbstractFileEngine::ExeOwnerPerm; + if (st.st_mode & S_IRUSR) + ret |= QAbstractFileEngine::ReadUserPerm; + if (st.st_mode & S_IWUSR) + ret |= QAbstractFileEngine::WriteUserPerm; + if (st.st_mode & S_IXUSR) + ret |= QAbstractFileEngine::ExeUserPerm; + if (st.st_mode & S_IRGRP) + ret |= QAbstractFileEngine::ReadGroupPerm; + if (st.st_mode & S_IWGRP) + ret |= QAbstractFileEngine::WriteGroupPerm; + if (st.st_mode & S_IXGRP) + ret |= QAbstractFileEngine::ExeGroupPerm; + if (st.st_mode & S_IROTH) + ret |= QAbstractFileEngine::ReadOtherPerm; + if (st.st_mode & S_IWOTH) + ret |= QAbstractFileEngine::WriteOtherPerm; + if (st.st_mode & S_IXOTH) + ret |= QAbstractFileEngine::ExeOtherPerm; + + return ret; +} + +/*! \reimp */ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const @@ -755,32 +790,8 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const if (!exists && !d->isSymlink()) return ret; - if (exists && (type & PermsMask)) { - if (d->st.st_mode & S_IRUSR) - ret |= ReadOwnerPerm; - if (d->st.st_mode & S_IWUSR) - ret |= WriteOwnerPerm; - if (d->st.st_mode & S_IXUSR) - ret |= ExeOwnerPerm; - if (d->st.st_mode & S_IRUSR) - ret |= ReadUserPerm; - if (d->st.st_mode & S_IWUSR) - ret |= WriteUserPerm; - if (d->st.st_mode & S_IXUSR) - ret |= ExeUserPerm; - if (d->st.st_mode & S_IRGRP) - ret |= ReadGroupPerm; - if (d->st.st_mode & S_IWGRP) - ret |= WriteGroupPerm; - if (d->st.st_mode & S_IXGRP) - ret |= ExeGroupPerm; - if (d->st.st_mode & S_IROTH) - ret |= ReadOtherPerm; - if (d->st.st_mode & S_IWOTH) - ret |= WriteOtherPerm; - if (d->st.st_mode & S_IXOTH) - ret |= ExeOtherPerm; - } + if (exists && (type & PermsMask)) + ret |= d->getPermissions(); if (type & TypesMask) { #if !defined(QWS) && defined(Q_OS_MAC) bool foundAlias = false; |