Filepath: Add ensureReachable function

ensureReachable checks whether the device (if any) of the filepath
can "reach" another FilePath. Devices can then either return false
if they don't, or take action to ensure that the path can be reached.

Change-Id: Ic1a315b9e7d9e37ee649989313a4cdb195a7e4d9
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-09-14 09:55:30 +02:00
parent cc6a7b113a
commit 88969b79eb
5 changed files with 29 additions and 0 deletions

View File

@@ -559,6 +559,18 @@ std::optional<QByteArray> FilePath::fileContents(qint64 maxSize, qint64 offset)
return f.readAll();
}
bool FilePath::ensureReachable(const FilePath &other) const
{
if (needsDevice()) {
QTC_ASSERT(s_deviceHooks.ensureReachable, return false);
return s_deviceHooks.ensureReachable(*this, other);
} else if (!other.needsDevice()) {
return true;
}
return false;
}
void FilePath::asyncFileContents(const Continuation<const std::optional<QByteArray> &> &cont,
qint64 maxSize,
qint64 offset) const