• 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
32     {
33         return items_;
34     };
SetModuleName(const std::string & moduleName)35     void SetModuleName(const std::string &moduleName)
36     {
37         moduleName_ = moduleName;
38     };
39     uint32_t ScanIncrement(const std::string &output);
40     uint32_t MergeResourceItem(const std::map<int32_t, std::vector<ResourceItem>> &resourceInfos);
41 
42 private:
43     uint32_t ScanModule(const std::string &input, const std::string &output,
44         std::map<ResType, std::vector<DirectoryInfo>> &resTypeOfDirs);
45     uint32_t ParseReference(const std::string &output, const std::vector<std::string> &sxmlFolders);
46     bool NeedParseReferenceInSolidXml(ResType resType) const;
47     void FilterRefSolidXml(const std::string &output, std::vector<std::string> &outputPaths,
48         const std::map<ResType, std::vector<DirectoryInfo>> &resTypeOfDirs) const;
49 
50     // id, resource items
51     std::map<int32_t, std::vector<ResourceItem>> items_;
52     std::string moduleName_;
53 };
54 }
55 }
56 }
57 #endif
58