Simplify permission flag handling a bit

Change-Id: I753f7a398c39e7300821658f27e4813c591eebc3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Konstantin Ritt 2015-04-07 16:46:40 +04:00
parent a79dd87f3f
commit 9901bfe914
3 changed files with 11 additions and 31 deletions

View File

@ -662,17 +662,11 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &
bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
{ {
mode_t mode = 0; mode_t mode = 0;
if (permissions & QFile::ReadOwner) if (permissions & (QFile::ReadOwner | QFile::ReadUser))
mode |= S_IRUSR; mode |= S_IRUSR;
if (permissions & QFile::WriteOwner) if (permissions & (QFile::WriteOwner | QFile::WriteUser))
mode |= S_IWUSR; mode |= S_IWUSR;
if (permissions & QFile::ExeOwner) if (permissions & (QFile::ExeOwner | QFile::ExeUser))
mode |= S_IXUSR;
if (permissions & QFile::ReadUser)
mode |= S_IRUSR;
if (permissions & QFile::WriteUser)
mode |= S_IWUSR;
if (permissions & QFile::ExeUser)
mode |= S_IXUSR; mode |= S_IXUSR;
if (permissions & QFile::ReadGroup) if (permissions & QFile::ReadGroup)
mode |= S_IRGRP; mode |= S_IRGRP;

View File

@ -1437,11 +1437,9 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per
Q_UNUSED(data); Q_UNUSED(data);
int mode = 0; int mode = 0;
if (permissions & QFile::ReadOwner || permissions & QFile::ReadUser if (permissions & (QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther))
|| permissions & QFile::ReadGroup || permissions & QFile::ReadOther)
mode |= _S_IREAD; mode |= _S_IREAD;
if (permissions & QFile::WriteOwner || permissions & QFile::WriteUser if (permissions & (QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther))
|| permissions & QFile::WriteGroup || permissions & QFile::WriteOther)
mode |= _S_IWRITE; mode |= _S_IWRITE;
if (mode == 0) // not supported if (mode == 0) // not supported

View File

@ -162,17 +162,11 @@ static void writeMSDosDate(uchar *dest, const QDateTime& dt)
static quint32 permissionsToMode(QFile::Permissions perms) static quint32 permissionsToMode(QFile::Permissions perms)
{ {
quint32 mode = 0; quint32 mode = 0;
if (perms & QFile::ReadOwner) if (perms & (QFile::ReadOwner | QFile::ReadUser))
mode |= S_IRUSR; mode |= S_IRUSR;
if (perms & QFile::WriteOwner) if (perms & (QFile::WriteOwner | QFile::WriteUser))
mode |= S_IWUSR; mode |= S_IWUSR;
if (perms & QFile::ExeOwner) if (perms & (QFile::ExeOwner | QFile::ExeUser))
mode |= S_IXUSR;
if (perms & QFile::ReadUser)
mode |= S_IRUSR;
if (perms & QFile::WriteUser)
mode |= S_IWUSR;
if (perms & QFile::ExeUser)
mode |= S_IXUSR; mode |= S_IXUSR;
if (perms & QFile::ReadGroup) if (perms & QFile::ReadGroup)
mode |= S_IRGRP; mode |= S_IRGRP;
@ -257,17 +251,11 @@ static QFile::Permissions modeToPermissions(quint32 mode)
{ {
QFile::Permissions ret; QFile::Permissions ret;
if (mode & S_IRUSR) if (mode & S_IRUSR)
ret |= QFile::ReadOwner; ret |= QFile::ReadOwner | QFile::ReadUser;
if (mode & S_IWUSR) if (mode & S_IWUSR)
ret |= QFile::WriteOwner; ret |= QFile::WriteOwner | QFile::WriteUser;
if (mode & S_IXUSR) if (mode & S_IXUSR)
ret |= QFile::ExeOwner; ret |= QFile::ExeOwner | QFile::ExeUser;
if (mode & S_IRUSR)
ret |= QFile::ReadUser;
if (mode & S_IWUSR)
ret |= QFile::WriteUser;
if (mode & S_IXUSR)
ret |= QFile::ExeUser;
if (mode & S_IRGRP) if (mode & S_IRGRP)
ret |= QFile::ReadGroup; ret |= QFile::ReadGroup;
if (mode & S_IWGRP) if (mode & S_IWGRP)