From 6e13510f9559a55bf38906c773575fa2c47c0e1f Mon Sep 17 00:00:00 2001 From: zt147369 Date: Wed, 10 Jan 2024 10:52:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Did=5Fdefined=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zt147369 --- README_zh.md | 2 +- include/resource_data.h | 2 +- src/id_worker.cpp | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README_zh.md b/README_zh.md index dc6c0e7..afddf12 100644 --- a/README_zh.md +++ b/README_zh.md @@ -105,7 +105,7 @@ restool -i out1 -i out2 -o out -p com.ohos.demo -r out/ResourceTable.txt -j entr 生成id_defined.json文件: ``` -restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt --ids out/id_defined.json -f +restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt --ids out -f ``` 指定资源ID固定的id_defined.json文件: diff --git a/include/resource_data.h b/include/resource_data.h index 1f58628..31cf3d5 100644 --- a/include/resource_data.h +++ b/include/resource_data.h @@ -40,7 +40,7 @@ const static std::string LONG_PATH_HEAD = "\\\\?\\"; const static std::string ID_DEFINED_INDENTATION = " "; const static int32_t VERSION_MAX_LEN = 128; const static int32_t INT_TO_BYTES = sizeof(uint32_t); -static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 4.104" }; +static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 4.105" }; const static int32_t TAG_LEN = 4; enum class KeyType { diff --git a/src/id_worker.cpp b/src/id_worker.cpp index de3c29c..f622a3a 100644 --- a/src/id_worker.cpp +++ b/src/id_worker.cpp @@ -394,9 +394,17 @@ bool IdWorker::PushResourceId(const ResourceId &resourceId, bool isSystem) return false; } if (isSystem) { - sysDefinedIds_.emplace(make_pair(resType, resourceId.name), resourceId); + auto ret1 = sysDefinedIds_.emplace(make_pair(resType, resourceId.name), resourceId); + if (!ret1.second) { + cerr << "Error: the same type of '" << resourceId.name << "' exists in the id_defined.json. " << endl; + return false; + } } else { - appDefinedIds_.emplace(make_pair(resType, resourceId.name), resourceId); + auto ret2 = appDefinedIds_.emplace(make_pair(resType, resourceId.name), resourceId); + if (!ret2.second) { + cerr << "Error: the same type of '" << resourceId.name << "' exists in the id_defined.json. " << endl; + return false; + } } return true; }