aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/filestreamermanager.h
blob: f86a3db480fda5c4f6ebfed40ad30bfc686db192 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "utils_global.h"

#include "filepath.h"

#include <QObject>

QT_BEGIN_NAMESPACE
class QByteArray;
QT_END_NAMESPACE

namespace Utils {

enum class FileStreamHandle : int {};

class QTCREATOR_UTILS_EXPORT FileStreamerManager
{
public:
    static FileStreamHandle copy(const FilePath &source, const FilePath &destination,
                                 const CopyContinuation &cont);
    static FileStreamHandle copy(const FilePath &source, const FilePath &destination,
                                 QObject *context, const CopyContinuation &cont);

    static FileStreamHandle read(const FilePath &source, const ReadContinuation &cont = {});
    static FileStreamHandle read(const FilePath &source, QObject *context,
                                 const ReadContinuation &cont = {});

    static FileStreamHandle write(const FilePath &destination, const QByteArray &data,
                                  const WriteContinuation &cont = {});
    static FileStreamHandle write(const FilePath &destination, const QByteArray &data,
                                  QObject *context, const WriteContinuation &cont = {});

    // If called from the same thread that started the task, no continuation is going to be called.
    static void stop(FileStreamHandle handle);
    static void stopAll();
};

} // namespace Utils