forked from qt-creator/qt-creator
Utils: Add FilePath.hasFileAccess()
FilePath::hasFileAccess allows a user to test if a specific device
can access files. This is faster than calling "exists()" as it does
not have to actually check anything on the device.
cherry picked from commit 21ef25a0f5
Task-number: QTCREATORBUG-28531
Change-Id: I363ca634d921464fe4ec68397c09fba49dccee25
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -826,6 +826,12 @@ DeviceFileAccess *FilePath::fileAccess() const
|
||||
return access;
|
||||
}
|
||||
|
||||
bool FilePath::hasFileAccess() const
|
||||
{
|
||||
DeviceFileAccess *access = s_deviceHooks.fileAccess(*this);
|
||||
return access;
|
||||
}
|
||||
|
||||
/// Constructs a FilePath from \a filePath. The \a defaultExtension is appended
|
||||
/// to \a filename if that does not have an extension already.
|
||||
/// \a filePath is not checked for validity.
|
||||
|
@@ -207,6 +207,7 @@ public:
|
||||
// There are usually other means available. E.g. distinguishing based
|
||||
// on FilePath::osType().
|
||||
bool needsDevice() const;
|
||||
bool hasFileAccess() const;
|
||||
|
||||
bool isSameDevice(const FilePath &other) const;
|
||||
bool isSameFile(const FilePath &other) const;
|
||||
|
@@ -36,6 +36,7 @@ FilePaths FSEngine::registeredDeviceRoots()
|
||||
|
||||
void FSEngine::addDevice(const FilePath &deviceRoot)
|
||||
{
|
||||
if (deviceRoot.hasFileAccess())
|
||||
deviceRoots().append(deviceRoot);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user