修复id_defined相关问题

Signed-off-by: zt147369 <zhangting201@huawei.com>
This commit is contained in:
zt147369
2024-01-10 10:52:08 +08:00
parent 9ed3f43830
commit 6e13510f95
3 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -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文件:
+1 -1
View File
@@ -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 {
+10 -2
View File
@@ -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;
}