forked from qt-creator/qt-creator
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:
@@ -829,6 +829,19 @@ QByteArray UnixDeviceFileAccess::fileId(const FilePath &filePath) const
|
|||||||
|
|
||||||
FilePathInfo UnixDeviceFileAccess::filePathInfo(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});
|
const RunResult stat = runInShell({"stat", {"-L", "-c", "%f %Y %s", filePath.path()}, OsType::OsTypeLinux});
|
||||||
return FileUtils::filePathInfoFromTriple(QString::fromLatin1(stat.stdOut));
|
return FileUtils::filePathInfoFromTriple(QString::fromLatin1(stat.stdOut));
|
||||||
}
|
}
|
||||||
|
@@ -415,26 +415,30 @@ FilePath qUrlToFilePath(const QUrl &url)
|
|||||||
|
|
||||||
QUrl filePathToQUrl(const FilePath &filePath)
|
QUrl filePathToQUrl(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
return QUrl::fromLocalFile(filePath.toFSPathString());
|
return QUrl::fromLocalFile(filePath.toFSPathString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareNonNativeDialog(QFileDialog &dialog)
|
void prepareNonNativeDialog(QFileDialog &dialog)
|
||||||
{
|
{
|
||||||
|
const auto isValidSideBarPath = [](const FilePath &fp) {
|
||||||
|
return !fp.needsDevice() || fp.hasFileAccess();
|
||||||
|
};
|
||||||
|
|
||||||
// Checking QFileDialog::itemDelegate() seems to be the only way to determine
|
// Checking QFileDialog::itemDelegate() seems to be the only way to determine
|
||||||
// whether the dialog is native or not.
|
// whether the dialog is native or not.
|
||||||
if (dialog.itemDelegate()) {
|
if (dialog.itemDelegate()) {
|
||||||
FilePaths sideBarPaths;
|
FilePaths sideBarPaths;
|
||||||
|
|
||||||
// Check existing urls, remove paths that need a device and no longer exist.
|
// Check existing urls, remove paths that need a device and are no longer valid.
|
||||||
for (const QUrl &url : dialog.sidebarUrls()) {
|
for (const QUrl &url : dialog.sidebarUrls()) {
|
||||||
FilePath path = qUrlToFilePath(url);
|
FilePath path = qUrlToFilePath(url);
|
||||||
if (!path.needsDevice() || path.exists())
|
if (isValidSideBarPath(path))
|
||||||
sideBarPaths.append(path);
|
sideBarPaths.append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all device roots that are not already in the sidebar and exist.
|
// Add all device roots that are not already in the sidebar and valid.
|
||||||
for (const FilePath &path : FSEngine::registeredDeviceRoots()) {
|
for (const FilePath &path : FSEngine::registeredDeviceRoots()) {
|
||||||
if (!sideBarPaths.contains(path) && path.exists())
|
if (!sideBarPaths.contains(path) && isValidSideBarPath(path))
|
||||||
sideBarPaths.append(path);
|
sideBarPaths.append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,6 +44,9 @@ bool FSEngineImpl::open(QIODevice::OpenMode openMode)
|
|||||||
createCacheData);
|
createCacheData);
|
||||||
bool exists = (data.filePathInfo.fileFlags & QAbstractFileEngine::ExistsFlag);
|
bool exists = (data.filePathInfo.fileFlags & QAbstractFileEngine::ExistsFlag);
|
||||||
|
|
||||||
|
if (data.filePathInfo.fileFlags & QAbstractFileEngine::DirectoryType)
|
||||||
|
return false;
|
||||||
|
|
||||||
g_filePathInfoCache.invalidate(m_filePath);
|
g_filePathInfoCache.invalidate(m_filePath);
|
||||||
|
|
||||||
ensureStorage();
|
ensureStorage();
|
||||||
|
@@ -23,6 +23,7 @@ WebAssemblyDevice::WebAssemblyDevice()
|
|||||||
setDeviceState(IDevice::DeviceStateUnknown);
|
setDeviceState(IDevice::DeviceStateUnknown);
|
||||||
setMachineType(IDevice::Hardware);
|
setMachineType(IDevice::Hardware);
|
||||||
setOsType(OsTypeOther);
|
setOsType(OsTypeOther);
|
||||||
|
setFileAccess(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::Ptr WebAssemblyDevice::create()
|
IDevice::Ptr WebAssemblyDevice::create()
|
||||||
|
Reference in New Issue
Block a user