mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 17:24:42 -04:00
@@ -292,6 +292,9 @@ string CompressionParser::ParseJsonStr(const cJSON *node)
|
||||
return "";
|
||||
}
|
||||
char *jsonString = cJSON_Print(node);
|
||||
if (jsonString == nullptr) {
|
||||
return "";
|
||||
}
|
||||
string res(jsonString);
|
||||
free(jsonString);
|
||||
return res;
|
||||
|
||||
@@ -291,6 +291,10 @@ int64_t IdDefinedParser::GetStartId() const
|
||||
}
|
||||
|
||||
int64_t id = strtoll(startIdNode->valuestring, nullptr, 16);
|
||||
if (id == 0) {
|
||||
cerr << "Error: id_defined.json 'startId' is not a valid hexadecimal string." << endl;
|
||||
return -1;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,10 @@ uint32_t ReferenceParser::ParseRefInResourceItem(ResourceItem &resourceItem) con
|
||||
string data;
|
||||
bool update = false;
|
||||
if (IsStringOfResourceItem(resType)) {
|
||||
if (resourceItem.GetData() == nullptr) {
|
||||
cerr << "Error: parse ref in resource item failed, data is null." << endl;
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
data = string(reinterpret_cast<const char *>(resourceItem.GetData()), resourceItem.GetDataLength());
|
||||
if (!ParseRefString(data, update)) {
|
||||
cerr << "Error: please check JSON file." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl;
|
||||
@@ -182,6 +186,10 @@ bool ReferenceParser::ParseRefJson(const string &from, const string &to)
|
||||
|
||||
bool ReferenceParser::ParseRefResourceItemData(const ResourceItem &resourceItem, string &data, bool &update) const
|
||||
{
|
||||
if (resourceItem.GetData() == nullptr) {
|
||||
cerr << "Error: parse ref resource item data failed, data is null." << endl;
|
||||
return false;
|
||||
}
|
||||
data = string(reinterpret_cast<const char *>(resourceItem.GetData()), resourceItem.GetDataLength());
|
||||
vector<string> contents = ResourceUtil::DecomposeStrings(data);
|
||||
if (contents.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user