forked from qt-creator/qt-creator
Docker: Implement DockerDevice::permissions()
Change-Id: Ib2daf4a631c5c1bf851720b7094f027ce11dd3e0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1296,6 +1296,33 @@ qint64 DockerDevice::fileSize(const FilePath &filePath) const
|
|||||||
return output.toLongLong();
|
return output.toLongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFileDevice::Permissions DockerDevice::permissions(const FilePath &filePath) const
|
||||||
|
{
|
||||||
|
QTC_ASSERT(handlesFile(filePath), return {});
|
||||||
|
tryCreateLocalFileAccess();
|
||||||
|
if (hasLocalFileAccess()) {
|
||||||
|
const FilePath localAccess = mapToLocalAccess(filePath);
|
||||||
|
LOG("Permissions? " << filePath.toUserOutput() << localAccess.toUserOutput() << localAccess.permissions());
|
||||||
|
return localAccess.permissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString output = d->outputForRunInShell({"stat", {"-c", "%a", filePath.path()}});
|
||||||
|
const uint bits = output.toUInt(nullptr, 8);
|
||||||
|
QFileDevice::Permissions perm = {};
|
||||||
|
#define BIT(n, p) if (bits & (1<<n)) perm |= QFileDevice::p
|
||||||
|
BIT(0, ExeOther);
|
||||||
|
BIT(1, WriteOther);
|
||||||
|
BIT(2, ReadOther);
|
||||||
|
BIT(3, ExeGroup);
|
||||||
|
BIT(4, WriteGroup);
|
||||||
|
BIT(5, ReadGroup);
|
||||||
|
BIT(6, ExeUser);
|
||||||
|
BIT(7, WriteUser);
|
||||||
|
BIT(8, ReadUser);
|
||||||
|
#undef BIT
|
||||||
|
return perm;
|
||||||
|
}
|
||||||
|
|
||||||
static FilePaths filterEntriesHelper(const FilePath &base,
|
static FilePaths filterEntriesHelper(const FilePath &base,
|
||||||
const QStringList &entries,
|
const QStringList &entries,
|
||||||
const QStringList &nameFilters,
|
const QStringList &nameFilters,
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public:
|
|||||||
QDateTime lastModified(const Utils::FilePath &filePath) const override;
|
QDateTime lastModified(const Utils::FilePath &filePath) const override;
|
||||||
void runProcess(Utils::QtcProcess &process) const override;
|
void runProcess(Utils::QtcProcess &process) const override;
|
||||||
qint64 fileSize(const Utils::FilePath &filePath) const override;
|
qint64 fileSize(const Utils::FilePath &filePath) const override;
|
||||||
|
QFileDevice::Permissions permissions(const Utils::FilePath &filePath) const override;
|
||||||
|
|
||||||
Utils::Environment systemEnvironment() const override;
|
Utils::Environment systemEnvironment() const override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user