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 { return items_; }; GetScanDirs()48 const std::map<ResType, std::vector<DirectoryInfo>> &GetScanDirs() const { return scanDirs_; }; FirstIncrement()49 bool FirstIncrement() const { return firstIncrement_; }; Enable()50 bool Enable() const { return enalbe_; }; 51 52 static const std::string ID_JSON_FILE; 53 private: 54 bool InitIdJson(); 55 bool InitList(std::vector<IncrementList::FileIncrement> &dels) const; 56 bool ScanModules(const std::vector<IncrementList::FileIncrement> &dels); 57 void FlushId(); 58 bool SaveIdJson() const; 59 bool LoadIdJson(); 60 void PushScanDir(const std::map<ResType, std::vector<DirectoryInfo>> &scanDirs); 61 void DeleteRawFile(std::vector<IncrementList::FileIncrement> &dels) const; 62 bool ClearSolidXml() const; 63 std::string cachePath_; 64 std::vector<std::string> folder_; 65 std::string outputPath_; 66 std::string moduleName_; 67 std::map<int32_t, std::vector<ResourceItem>> items_; 68 std::map<ResType, std::vector<DirectoryInfo>> scanDirs_; 69 bool enalbe_ = false; 70 bool firstIncrement_ = true; 71 }; 72 } 73 } 74 } 75 #endif 76