QFileSystemEngine: remove QFSMetaData* parameter from setPermissions()
Nothing passes a QFileSystemMetaData* to any of those methods. Add QFileSystemMetaData::setPermissions(), which contains the code that used to be in QFileSystemEngine::setPermissions(); callers can use it directly to set the permissions on a QFileSystemMetaData object, after the QFileSystemEngine::setPermissions() call succeeds. Change-Id: I9f3415e969680f3b7039a7a8982032349e0133e1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
353ce5344f
commit
b6ab002b3b
@ -91,8 +91,7 @@ public:
|
||||
static QByteArray id(int fd);
|
||||
static bool setFileTime(int fd, const QDateTime &newDate,
|
||||
QFile::FileTime whatTime, QSystemError &error);
|
||||
static bool setPermissions(int fd, QFile::Permissions permissions, QSystemError &error,
|
||||
QFileSystemMetaData *data = nullptr);
|
||||
static bool setPermissions(int fd, QFile::Permissions permissions, QSystemError &error);
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
static QFileSystemEntry junctionTarget(const QFileSystemEntry &link, QFileSystemMetaData &data);
|
||||
@ -147,8 +146,8 @@ public:
|
||||
static bool renameOverwriteFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
|
||||
static bool removeFile(const QFileSystemEntry &entry, QSystemError &error);
|
||||
|
||||
static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error,
|
||||
QFileSystemMetaData *data = nullptr);
|
||||
static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions,
|
||||
QSystemError &error);
|
||||
|
||||
// unused, therefore not implemented
|
||||
static bool setFileTime(const QFileSystemEntry &entry, const QDateTime &newDate,
|
||||
|
@ -1727,33 +1727,23 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &
|
||||
}
|
||||
|
||||
//static
|
||||
bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
|
||||
bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry,
|
||||
QFile::Permissions permissions, QSystemError &error)
|
||||
{
|
||||
Q_CHECK_FILE_NAME(entry, false);
|
||||
|
||||
mode_t mode = QtPrivate::toMode_t(permissions);
|
||||
bool success = ::chmod(entry.nativeFilePath().constData(), mode) == 0;
|
||||
if (success && data) {
|
||||
data->entryFlags &= ~QFileSystemMetaData::Permissions;
|
||||
data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions.toInt()));
|
||||
data->knownFlagsMask |= QFileSystemMetaData::Permissions;
|
||||
}
|
||||
if (!success)
|
||||
error = QSystemError(errno, QSystemError::StandardLibraryError);
|
||||
return success;
|
||||
}
|
||||
|
||||
//static
|
||||
bool QFileSystemEngine::setPermissions(int fd, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
|
||||
bool QFileSystemEngine::setPermissions(int fd, QFile::Permissions permissions, QSystemError &error)
|
||||
{
|
||||
mode_t mode = QtPrivate::toMode_t(permissions);
|
||||
|
||||
bool success = ::fchmod(fd, mode) == 0;
|
||||
if (success && data) {
|
||||
data->entryFlags &= ~QFileSystemMetaData::Permissions;
|
||||
data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions.toInt()));
|
||||
data->knownFlagsMask |= QFileSystemMetaData::Permissions;
|
||||
}
|
||||
if (!success)
|
||||
error = QSystemError(errno, QSystemError::StandardLibraryError);
|
||||
return success;
|
||||
|
@ -1852,12 +1852,10 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
|
||||
|
||||
//static
|
||||
bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry,
|
||||
QFile::Permissions permissions, QSystemError &error,
|
||||
QFileSystemMetaData *data)
|
||||
QFile::Permissions permissions, QSystemError &error)
|
||||
{
|
||||
Q_CHECK_FILE_NAME(entry, false);
|
||||
|
||||
Q_UNUSED(data);
|
||||
int mode = 0;
|
||||
|
||||
if (permissions & (QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther))
|
||||
|
@ -182,6 +182,9 @@ public:
|
||||
qint64 size() const { return size_; }
|
||||
|
||||
inline QFile::Permissions permissions() const;
|
||||
// Has to be defined after the
|
||||
// Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags) call below.
|
||||
inline void setPermissions(QFile::Permissions permissions);
|
||||
|
||||
QDateTime accessTime() const;
|
||||
QDateTime birthTime() const;
|
||||
@ -240,6 +243,13 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags)
|
||||
|
||||
inline QFile::Permissions QFileSystemMetaData::permissions() const { return QFile::Permissions::fromInt((Permissions & entryFlags).toInt()); }
|
||||
|
||||
void QFileSystemMetaData::setPermissions(QFile::Permissions permissions)
|
||||
{
|
||||
entryFlags &= ~Permissions;
|
||||
entryFlags |= MetaDataFlag(uint(permissions.toInt()));
|
||||
knownFlagsMask |= Permissions;
|
||||
}
|
||||
|
||||
#if defined(Q_OS_DARWIN)
|
||||
inline bool QFileSystemMetaData::isBundle() const { return entryFlags.testAnyFlag(BundleType); }
|
||||
inline bool QFileSystemMetaData::isAlias() const { return entryFlags.testAnyFlag(AliasType); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user