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_MANAGER_H 17 #define OHOS_RESTOOL_INCREMENT_MANAGER_H 18 19 #include<string> 20 #include "resource_util.h" 21 #include "resource_item.h" 22 #include "singleton.h" 23 24 #include "increment_list.h" 25 #include "increment_index.h" 26 27 namespace OHOS { 28 namespace Global { 29 namespace Restool { 30 class IncrementManager : public Singleton<IncrementManager> { 31 public: 32 struct FileIncrement : FileInfo { 33 std::string extension; 34 std::string relativePath; 35 std::string inputPath; 36 int32_t priority; 37 }; 38 39 struct ModuleInfo { 40 std::string rootPath; 41 std::vector<IncrementList::FileIncrement> fileIncrements; 42 }; 43 44 virtual ~IncrementManager(); 45 uint32_t Init(const std::string &cachePath, const std::vector<std::string> &folder, 46 const std::string &outputPath, const std::string &moduleName); GetResourceItems()47 const std::map<int32_t, std::vector<ResourceItem>> &GetResourceItems() const 48 { 49 return items_; 50 }; GetScanDirs()51 const std::map<ResType, std::vector<DirectoryInfo>> &GetScanDirs() const 52 { 53 return scanDirs_; 54 }; FirstIncrement()55 bool FirstIncrement() const 56 { 57 return firstIncrement_; 58 }; Enable()59 bool Enable() const 60 { 61 return enalbe_; 62 }; 63 64 static const std::string ID_JSON_FILE; 65 private: 66 bool InitIdJson(); 67 bool InitList(std::vector<IncrementList::FileIncrement> &dels) const; 68 bool ScanModules(const std::vector<IncrementList::FileIncrement> &dels); 69 void FlushId(); 70 bool SaveIdJson() const; 71 bool LoadIdJson(); 72 void PushScanDir(const std::map<ResType, std::vector<DirectoryInfo>> &scanDirs); 73 void DeleteRawFile(std::vector<IncrementList::FileIncrement> &dels) const; 74 bool ClearSolidXml() const; 75 std::string cachePath_; 76 std::vector<std::string> folder_; 77 std::string outputPath_; 78 std::string moduleName_; 79 std::map<int32_t, std::vector<ResourceItem>> items_; 80 std::map<ResType, std::vector<DirectoryInfo>> scanDirs_; 81 bool enalbe_ = false; 82 bool firstIncrement_ = true; 83 }; 84 } 85 } 86 } 87 #endif 88