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_FILE_MANAGER_H 17#define OHOS_RESTOOL_FILE_MANAGER_H 18 19#include <vector> 20#include "resource_data.h" 21#include "resource_item.h" 22#include "singleton.h" 23 24namespace OHOS { 25namespace Global { 26namespace Restool { 27class FileManager : public Singleton<FileManager> { 28public: 29 uint32_t ScanModules(const std::vector<std::string> &inputs, const std::string &output, const bool isHar); 30 const std::map<int64_t, std::vector<ResourceItem>> &GetResources() const 31 { 32 return items_; 33 }; 34 void SetModuleName(const std::string &moduleName) 35 { 36 moduleName_ = moduleName; 37 }; 38 uint32_t MergeResourceItem(const std::map<int64_t, std::vector<ResourceItem>> &resourceInfos); 39 bool ScaleIcons(const std::string &output, const std::map<std::string, std::set<uint32_t>> &iconMap); 40 41private: 42 uint32_t ScanModule(const std::string &input, const std::string &output); 43 uint32_t ParseReference(const std::string &output); 44 void CheckAllItems(std::vector<std::pair<ResType, std::string>> &noBaseResource); 45 bool ScaleIcon(const std::string &output, ResourceItem &item); 46 47 // id, resource items 48 std::map<int64_t, std::vector<ResourceItem>> items_; 49 std::string moduleName_; 50}; 51} 52} 53} 54#endif 55