• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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_RESOURCE_CHECK_H
17 #define OHOS_RESTOOL_RESOURCE_CHECK_H
18 
19 #include "config_parser.h"
20 #include "resource_append.h"
21 #include "resource_item.h"
22 #include <iostream>
23 #include <stdint.h>
24 #include <map>
25 #include <set>
26 
27 namespace OHOS {
28 namespace Global {
29 namespace Restool {
30 
31 class ResourceCheck {
32 public:
33     ResourceCheck(const std::map<std::string, std::set<uint32_t>> &jsonCheckIds,
34         const std::shared_ptr<ResourceAppend> &resourceAppend = nullptr);
~ResourceCheck()35     virtual ~ResourceCheck() {};
36     void CheckConfigJson();
37     void CheckConfigJsonForCombine();
38 
39 private:
40     const std::map<std::string, std::set<uint32_t>> jsonCheckIds_;
41     const std::shared_ptr<ResourceAppend> resourceAppend_;
42     void CheckNodeInResourceItem(const std::string &key, const ResourceItem &resourceItem);
43     bool GetPngWidthAndHeight(const std::string &filePath, uint32_t *width, uint32_t *height);
44     bool IsValidPngImage(FILE *&in) const;
45     void CloseFile(FILE *fp);
46 };
47 
48 }
49 }
50 }
51 #endif