Utils: Fake root info

When trying to open a FileDialog all roots were tested for existence.
This is slow and might show ask-pass.

Since "/" can be considered always valid, we create a fake entry for it
and only test existence of remote paths if they are not a root path.

In the future FilePath should get a "isRoot()" function so we don't just
test for == "/".

Remove the fileAccess from WebAssembly devices.

Change-Id: I7a1a6e7d2025e9fd4428e4bd1d07cdbdb5680c8e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-01-19 08:05:43 +01:00
parent d36ecb23df
commit 598ffc3b1c
4 changed files with 26 additions and 5 deletions

View File

@@ -829,6 +829,19 @@ QByteArray UnixDeviceFileAccess::fileId(const FilePath &filePath) const
FilePathInfo UnixDeviceFileAccess::filePathInfo(const FilePath &filePath) const
{
if (filePath.path() == "/") // TODO: Add FilePath::isRoot()
{
const FilePathInfo r{4096,
FilePathInfo::FileFlags(
FilePathInfo::ReadOwnerPerm | FilePathInfo::WriteOwnerPerm
| FilePathInfo::ExeOwnerPerm | FilePathInfo::ReadGroupPerm
| FilePathInfo::ExeGroupPerm | FilePathInfo::ReadOtherPerm
| FilePathInfo::ExeOtherPerm | FilePathInfo::DirectoryType
| FilePathInfo::LocalDiskFlag | FilePathInfo::ExistsFlag),
QDateTime::currentDateTime()};
return r;
}
const RunResult stat = runInShell({"stat", {"-L", "-c", "%f %Y %s", filePath.path()}, OsType::OsTypeLinux});
return FileUtils::filePathInfoFromTriple(QString::fromLatin1(stat.stdOut));
}