1 /* 2 * Copyright (c) 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_FILEMGMT_BACKUP_B_JSON_CLEAR_DATA_CONFIG_H 17 #define OHOS_FILEMGMT_BACKUP_B_JSON_CLEAR_DATA_CONFIG_H 18 19 #include <mutex> 20 #include <string> 21 #include <vector> 22 23 namespace OHOS::FileManagement::Backup { 24 class BJsonClearDataConfig { 25 public: 26 /** 27 * @brief 判断配置文件中是否有记录 28 * 29 */ 30 bool HasClearBundleRecord(); 31 32 /** 33 * @brief 判断配置文件中是否存在bundleName记录 34 * 35 * @param bundlename 36 */ 37 bool FindClearBundleRecord(const std::string& bundleName); 38 39 /** 40 * @brief 配置文件中插入bundleName记录 41 * 42 * @param bundlename 43 */ 44 bool InsertClearBundleRecord(const std::string& bundleName); 45 46 /** 47 * @brief 配置文件中删除bundleName记录 48 * 49 * @param bundlename 50 */ 51 bool DeleteClearBundleRecord(const std::string& bundleName); 52 53 /** 54 * @brief 配置文件中获取bundlename 55 * 56 */ 57 std::vector<std::string> GetAllClearBundleRecords(); 58 59 /** 60 * @brief 删除配置文件 61 * 62 * 63 */ 64 bool DeleteConfigFile(); 65 66 public: 67 /** 68 * @brief 构造方法 69 * 70 * 71 */ 72 BJsonClearDataConfig(); 73 private: 74 /** 75 * @brief 配置文件中删除bundleName记录 76 * 77 * @param bundlename 78 */ 79 bool WriteClearBundleRecord(const std::string& bundleName); 80 81 private: 82 std::mutex fileMutex_; 83 }; 84 85 } // namespace OHOS::FileManagement::Backup 86 #endif // OHOS_FILEMGMT_BACKUP_B_JSON_CLEAR_DATA_CONFIG_H