From 9004a894f26994a44039a571c18e126e99ff40d3 Mon Sep 17 00:00:00 2001 From: "@ran-zhao-yu" Date: Wed, 10 Sep 2025 10:20:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E8=87=B4=E6=80=A7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: @ran-zhao-yu --- README_zh.md | 30 +----------------------------- src/id_defined_parser.cpp | 2 -- src/resource_item.cpp | 28 ++++++++++++++-------------- 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/README_zh.md b/README_zh.md index 9e921cf..2023f8f 100644 --- a/README_zh.md +++ b/README_zh.md @@ -68,34 +68,6 @@ Locale匹配规则:Locale匹配需满足以下三条规则。 参数举例说明:Locale[zh_CN,en_US];Device[phone],该参数过滤其他语言,保留能匹配上zh_CN和en_US的语言;过滤其他设备,保留phone;其他参数(如MccMnc、Orientation等)配置不过滤均保留。 - -#### restool支持的子命令 - -| 命令 | 描述 | -| --- | ---- | -| dump | 以json的格式输出hap包中resource的内容。 | - -**dump命令** - -``` -restool dump [-h] [config] filePath -``` -dump命令参数列表 - -| 参数 | 是否可缺省 | 是否存在入参 | 描述 | -| --- | --------- | ---------- |------- | -| -h | 可缺省 | 不带参数 | 帮助信息。 | -| config | 可缺省 | 不带参数 | 只打印hap包中资源的限定词信息。 | - -示例: - -```sh -# 打印hap包中所有的资源信息 -restool dump entry.hap -# 打印hap包中资源的限定词信息 -restool dump config entry.hap -``` - ### 使用实例 例如:entry目录结构如下 @@ -161,4 +133,4 @@ restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out [third_party_libpng](https://gitee.com/openharmony/third_party_libpng/blob/master/README.md) -[third_party_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function/blob/master/README.md ) +[third_party_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function/README.md) diff --git a/src/id_defined_parser.cpp b/src/id_defined_parser.cpp index bf8520a..490c742 100755 --- a/src/id_defined_parser.cpp +++ b/src/id_defined_parser.cpp @@ -221,8 +221,6 @@ bool IdDefinedParser::ParseId(const std::string &filePath, const cJSON *origId, bool IdDefinedParser::ParseType(const std::string &filePath, const cJSON *type, ResourceId &resourceId) { if (!type) { - std::string msg = "type"; - msg.append(cJSON_GetErrorPtr()); PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause("type").SetPosition(filePath)); return false; } diff --git a/src/resource_item.cpp b/src/resource_item.cpp index aa5f026..060274a 100644 --- a/src/resource_item.cpp +++ b/src/resource_item.cpp @@ -130,6 +130,20 @@ bool ResourceItem::IsCoverable() const return coverable_; } +void ResourceItem::CheckData() +{ + if (GetDataLength() == 0) { + return; + } + int8_t data[GetDataLength()]; + for (uint32_t i = 0; i < GetDataLength(); i++) { + data[i] = GetData()[i]; + } + if (data[GetDataLength() - 1] == '\0') { + SetData(data, GetDataLength() - 1); + } +} + bool ResourceItem::IsArray() const { return type_ == ResType::STRARRAY || type_ == ResType::INTARRAY; @@ -160,20 +174,6 @@ const std::vector ResourceItem::SplitValue() const return ret; } -void ResourceItem::CheckData() -{ - if (GetDataLength() == 0) { - return; - } - int8_t data[GetDataLength()]; - for (uint32_t i = 0; i < GetDataLength(); i++) { - data[i] = GetData()[i]; - } - if (data[GetDataLength() - 1] == '\0') { - SetData(data, GetDataLength() - 1); - } -} - ResourceItem &ResourceItem::operator=(const ResourceItem &other) { if (this == &other) { -- Gitee