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; }