/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_RESTOOL_INCREMENT_MANAGER_H #define OHOS_RESTOOL_INCREMENT_MANAGER_H #include #include "resource_util.h" #include "resource_item.h" #include "singleton.h" #include "increment_list.h" #include "increment_index.h" namespace OHOS { namespace Global { namespace Restool { class IncrementManager : public Singleton { public: struct FileIncrement : FileInfo { std::string extension; std::string relativePath; std::string inputPath; int32_t priority; }; struct ModuleInfo { std::string rootPath; std::vector fileIncrements; }; virtual ~IncrementManager(); uint32_t Init(const std::string &cachePath, const std::vector &folder, const std::string &outputPath, const std::string &moduleName); const std::map> &GetResourceItems() const { return items_; }; const std::map> &GetScanDirs() const { return scanDirs_; }; bool FirstIncrement() const { return firstIncrement_; }; bool Enable() const { return enalbe_; }; static const std::string ID_JSON_FILE; private: bool InitIdJson(); bool InitList(std::vector &dels) const; bool ScanModules(const std::vector &dels); void FlushId(); bool SaveIdJson() const; bool LoadIdJson(); void PushScanDir(const std::map> &scanDirs); void DeleteRawFile(std::vector &dels) const; bool ClearSolidXml() const; std::string cachePath_; std::vector folder_; std::string outputPath_; std::string moduleName_; std::map> items_; std::map> scanDirs_; bool enalbe_ = false; bool firstIncrement_ = true; }; } } } #endif