1 /* 2 * Copyright (c) 2021 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_INCREMENT_LIST_H 17 #define OHOS_RESTOOL_INCREMENT_LIST_H 18 19 #include<functional> 20 #include<vector> 21 #include "resource_data.h" 22 #include "resource_util.h" 23 24 namespace OHOS { 25 namespace Global { 26 namespace Restool { 27 class IncrementList { 28 public: 29 struct FileIncrement : FileInfo { 30 bool isDeleted; 31 std::string rootPath; 32 std::string relativePath; 33 }; 34 IncrementList(const std::string &listPath, const std::vector<std::string> &folder); ~IncrementList()35 virtual ~IncrementList() {}; 36 bool Parse(std::vector<FileIncrement> &fileList) const; 37 38 static const std::string RESTOOL_LIST_FILE; 39 private: 40 bool GetFromPath(const std::string &filePath, FileIncrement &info) const; 41 int32_t GetPriority(const std::string &filePath) const; 42 bool ParseSegment(const std::string &filePath, std::vector<std::string> &segments) const; 43 bool IteratorArray(const Json::Value &array, std::function<bool(const std::string &)> callback) const; 44 bool ParseArray(const Json::Value &array, std::vector<FileIncrement> &fileList, bool isDeleted) const; 45 const std::string &listPath_; 46 const std::vector<std::string> &folder_; 47 enum PathSegment { 48 SEG_RESOURCE = 0, 49 SEG_LIMIT_KEY = 1, 50 SEG_FILE_CLUSTER = 2, 51 SEG_FILE_NAME = 3, 52 SEG_MAX 53 }; 54 }; 55 } 56 } 57 } 58 #endif 59