diff options
author | Thomas Zander <t.zander@nokia.com> | 2010-09-22 12:00:55 (GMT) |
---|---|---|
committer | Thomas Zander <t.zander@nokia.com> | 2010-09-22 13:31:49 (GMT) |
commit | db9fb7195155f4ec929ae4ac73c5c5d4422e5aa6 (patch) | |
tree | 1fd1afcfe8119a842879b9eedab4f6a21853841f /src/corelib/io/qfilesystemengine_unix.cpp | |
parent | 9f2aee2a22d5a7c53480cc6c5794293bfe04cf8c (diff) | |
download | Qt-db9fb7195155f4ec929ae4ac73c5c5d4422e5aa6.zip Qt-db9fb7195155f4ec929ae4ac73c5c5d4422e5aa6.tar.gz Qt-db9fb7195155f4ec929ae4ac73c5c5d4422e5aa6.tar.bz2 |
Implement unix permissions setting
Reviewed-by: João Abecasis
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 0672490..e85eb00 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -43,6 +43,7 @@ #include "qfilesystemengine_p.h" #include "qplatformdefs.h" #include "qfsfileengine.h" +#include "qfile.h" #include <stdlib.h> // for realpath() #include <unistd.h> @@ -548,7 +549,33 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) //static bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) { - return false; // TODO implement; + mode_t mode = 0; + if (permissions & QFile::ReadOwner) + mode |= S_IRUSR; + if (permissions & QFile::WriteOwner) + mode |= S_IWUSR; + if (permissions & QFile::ExeOwner) + mode |= S_IXUSR; + if (permissions & QFile::ReadUser) + mode |= S_IRUSR; + if (permissions & QFile::WriteUser) + mode |= S_IWUSR; + if (permissions & QFile::ExeUser) + mode |= S_IXUSR; + if (permissions & QFile::ReadGroup) + mode |= S_IRGRP; + if (permissions & QFile::WriteGroup) + mode |= S_IWGRP; + if (permissions & QFile::ExeGroup) + mode |= S_IXGRP; + if (permissions & QFile::ReadOther) + mode |= S_IROTH; + if (permissions & QFile::WriteOther) + mode |= S_IWOTH; + if (permissions & QFile::ExeOther) + mode |= S_IXOTH; + + return ::chmod(entry.nativeFilePath().constData(), mode) == 0; } QString QFileSystemEngine::homePath() |