Utils: Start adding some asynchronous API to FilePath

Especially with the "remote" scenarios synchronous operations cannot
be expected to work reasonably well.

This here starts with adding asynchronous versions to some of the
FilePath member functions, taking additional "Continuation" style.

This is not necessarily the final syntax (sugar like .then(...) comes
to mind...), but is simple enough for now for the few uses we have,
and it is too early to see what will be needed in the end.

Change-Id: Idf4dde1b77d04cafb81b6c024031145bdd91a762
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-08-30 15:42:21 +02:00
parent 3c4e7321bf
commit ebf0917b9f
7 changed files with 83 additions and 4 deletions

View File

@@ -181,6 +181,13 @@ public:
static void removeDuplicates(QList<FilePath> &files);
static void sort(QList<FilePath> &files);
// Asynchronous interface
template <class ...Args> using Continuation = std::function<void(Args...)>;
void asyncCopyFile(const Continuation<bool> &cont, const FilePath &target) const;
void asyncFileContents(const Continuation<const QByteArray &> &cont,
qint64 maxSize = -1, qint64 offset = 0) const;
void asyncWriteFileContents(const Continuation<bool> &cont, const QByteArray &data) const;
private:
friend class ::tst_fileutils;
static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath);