• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
24 namespace OHOS {
25 namespace Global {
26 namespace Restool {
27 class FileManager : public Singleton<FileManager> {
28 public:
29     uint32_t ScanModules(const std::vector<std::string> &inputs, const std::string &output, const bool isHar);
GetResources()30     const std::map<int64_t, std::vector<ResourceItem>> &GetResources() const
31     {
32         return items_;
33     };
SetModuleName(const std::string & moduleName)34     void SetModuleName(const std::string &moduleName)
35     {
36         moduleName_ = moduleName;
37     };
GetModuleName()38     const std::string &GetModuleName() const
39     {
40         return moduleName_;
41     };
42     uint32_t MergeResourceItem(const std::map<int64_t, std::vector<ResourceItem>> &resourceInfos);
43     bool ScaleIcons(const std::string &output, const std::map<std::string, std::set<uint32_t>> &iconMap);
44     void SetScanHap(bool state);
45 
46 private:
47     uint32_t ScanModule(const std::string &input, const std::string &output);
48     uint32_t ParseReference(const std::string &output);
49     void CheckAllItems(std::vector<std::pair<ResType, std::string>> &noBaseResource);
50     bool ScaleIcon(const std::string &output, ResourceItem &item);
51 
52     // id, resource items
53     std::map<int64_t, std::vector<ResourceItem>> items_;
54     std::string moduleName_;
55     bool scanHap_ = false;
56 };
57 }
58 }
59 }
60 #endif
61