1/*
2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_RESTOOL_BINARY_FILE_PACKER_H
17#define OHOS_RESTOOL_BINARY_FILE_PACKER_H
18
19#include "cmd_parser.h"
20#include "resource_util.h"
21#include "thread_pool.h"
22
23namespace OHOS {
24namespace Global {
25namespace Restool {
26class BinaryFilePacker {
27public:
28    explicit BinaryFilePacker(const PackageParser &packageParser, const std::string &moduleName);
29    ~BinaryFilePacker();
30    std::future<uint32_t> CopyBinaryFileAsync(const std::vector<std::string> &inputs);
31    void StopCopy();
32
33private:
34    uint32_t CopyBinaryFile(const std::vector<std::string> &inputs);
35    uint32_t CopyBinaryFile(const std::string &filePath, const std::string &fileType);
36    uint32_t CopyBinaryFileImpl(const std::string &src, const std::string &dst);
37    uint32_t CopySingleFile(const std::string &path, std::string &subPath);
38    PackageParser packageParser_;
39    std::string moduleName_;
40    ThreadPool threadPool_;
41    std::vector<std::future<uint32_t>> copyResults_;
42    std::atomic<bool> stopCopy_{false};
43};
44} // namespace Restool
45} // namespace Global
46} // namespace OHOS
47#endif
48