1 /*
2  * Copyright (c) 2022-2023 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_FILEMGMT_BACKUP_B_JSON_ENTITY_EXT_MANAGE_H
17 #define OHOS_FILEMGMT_BACKUP_B_JSON_ENTITY_EXT_MANAGE_H
18 
19 #include <map>
20 #include <set>
21 #include <string>
22 #include <sys/stat.h>
23 
24 #include "b_json/b_json_cached_entity.h"
25 #include "json/json.h"
26 
27 namespace OHOS::FileManagement::Backup {
28 struct ExtManageInfo {
29     string hashName {""};
30     string fileName {""};
31     struct stat sta {};
32     bool isUserTar {false};
33     bool isBigFile {false};
34 };
35 class BJsonEntityExtManage : public BJsonEntity {
36 public:
37     /**
38      * @brief 设置索引文件
39      *
40      * @param info std::map<string, pair<string, struct stat>>
41      */
42     void SetExtManage(const map<string, tuple<string, struct stat, bool>> &info) const;
43 
44     /**
45      * @brief 设置索引文件(克隆)
46      *
47      * @param info map<string, tuple<string, struct stat, bool, bool>>
48      */
49     void SetExtManageForClone(const map<string, tuple<string, struct stat, bool, bool>> &info) const;
50 
51     /**
52      * @brief 获取索引文件
53      *
54      * @return std::set<std::string>
55      */
56     std::set<std::string> GetExtManage() const;
57 
58     /**
59      * @brief 获取索引文件及详细信息
60      *
61      * @return map<string, pair<string, struct stat>>
62      */
63     std::vector<ExtManageInfo> GetExtManageInfo() const;
64 
65 public:
66     /**
67      * @brief 构造方法,具备T(Json::Value&, std::any)能力的构造函数
68      *
69      * @param obj Json对象引用
70      * @param option 任意类型对象
71      */
72     explicit BJsonEntityExtManage(Json::Value &obj, std::any option = std::any()) : BJsonEntity(obj, option) {}
73 };
74 } // namespace OHOS::FileManagement::Backup
75 
76 #endif // OHOS_FILEMGMT_BACKUP_B_JSON_ENTITY_EXT_MANAGE_H