• 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 "increment_manager.h"
23 #include "singleton.h"
24 
25 namespace OHOS {
26 namespace Global {
27 namespace Restool {
28 class FileManager : public Singleton<FileManager> {
29 public:
30     uint32_t ScanModules(const std::vector<std::string> &inputs, const std::string &output);
GetResources()31     const std::map<int32_t, std::vector<ResourceItem>> &GetResources() const { return items_; };
SetModuleName(const std::string & moduleName)32     void SetModuleName(const std::string &moduleName) { moduleName_ = moduleName; };
33     uint32_t ScanIncrement(const std::string &output);
34     uint32_t MergeResourceItem(const std::map<int32_t, std::vector<ResourceItem>> &resourceInfos);
35 
36 private:
37     uint32_t ScanModule(const std::string &input, const std::string &output,
38         std::map<ResType, std::vector<DirectoryInfo>> &resTypeOfDirs);
39     uint32_t ParseReference(const std::string &output, const std::vector<std::string> &sxmlFolders);
40     bool NeedParseReferenceInSolidXml(ResType resType) const;
41     void FilterRefSolidXml(const std::string &output, std::vector<std::string> &outputPaths,
42         const std::map<ResType, std::vector<DirectoryInfo>> &resTypeOfDirs) const;
43 
44     // id, resource items
45     std::map<int32_t, std::vector<ResourceItem>> items_;
46     std::string moduleName_;
47 };
48 }
49 }
50 }
51 #endif
52