fix id overflow

Signed-off-by: liduo <liduo29@huawei.com>
This commit is contained in:
liduo
2024-07-20 20:52:33 +08:00
parent a136bd7337
commit 01b94736a0
7 changed files with 15 additions and 15 deletions
+4 -4
View File
@@ -40,10 +40,10 @@ public:
uint32_t Init();
const std::string &GetPackageName() const;
const std::string &GetModuleName() const;
int32_t GetAbilityIconId() const;
int32_t GetAbilityLabelId() const;
bool SetAppIcon(std::string &icon, int32_t id);
bool SetAppLabel(std::string &label, int32_t id);
int64_t GetAbilityIconId() const;
int64_t GetAbilityLabelId() const;
bool SetAppIcon(std::string &icon, int64_t id);
bool SetAppLabel(std::string &label, int64_t id);
ModuleType GetModuleType() const;
uint32_t ParseRefence();
uint32_t Save(const std::string &filePath) const;
+1 -1
View File
@@ -60,7 +60,7 @@ private:
std::string ParseString(const char buffer[], int32_t length, int32_t &offset) const;
int32_t ParseInt32(const char buffer[], int32_t length, int32_t &offset) const;
bool ParseRef();
bool CheckModuleResourceItem(const std::shared_ptr<ResourceItem> &resourceItem, int64_t id);
bool CheckModuleResourceItem(const std::shared_ptr<ResourceItem> &resourceItem, int64_t id);
bool IsBaseIdDefined(const FileInfo &fileInfo);
#ifdef __WIN32
bool LoadResourceItemWin(const std::string &filePath);
+3 -3
View File
@@ -34,7 +34,7 @@ public:
uint32_t LoadResTable(const std::string path, std::map<int64_t, std::vector<ResourceItem>> &resInfos);
private:
struct TableData {
int32_t id;
uint32_t id;
ResourceItem resourceItem;
};
@@ -54,13 +54,13 @@ private:
struct IdSet {
int8_t idTag[TAG_LEN] = {'I', 'D', 'S', 'S'};
uint32_t idCount;
std::map<int32_t, uint32_t> data; // pair id and offset
std::map<uint32_t, uint32_t> data; // pair id and offset
};
struct RecordItem {
uint32_t size;
int32_t resType;
int32_t id;
uint32_t id;
};
uint32_t SaveToResouorceIndex(const std::map<std::string, std::vector<TableData>> &configs) const;
uint32_t CreateIdDefined(const std::map<int64_t, std::vector<ResourceItem>> &allResource) const;
+1 -1
View File
@@ -172,7 +172,7 @@ public:
* @param int32_t Decimal
* @return Hexadecimal string
*/
static std::string DecToHexStr(const int32_t id);
static std::string DecToHexStr(const uint32_t id);
/**
* @brief Check hexadecimal string
+4 -4
View File
@@ -98,12 +98,12 @@ const string &ConfigParser::GetModuleName() const
return moduleName_;
}
int32_t ConfigParser::GetAbilityIconId() const
int64_t ConfigParser::GetAbilityIconId() const
{
return abilityIconId_;
}
int32_t ConfigParser::GetAbilityLabelId() const
int64_t ConfigParser::GetAbilityLabelId() const
{
return abilityLabelId_;
}
@@ -129,7 +129,7 @@ uint32_t ConfigParser::Save(const string &filePath) const
return RESTOOL_ERROR;
}
bool ConfigParser::SetAppIcon(string &icon, int32_t id)
bool ConfigParser::SetAppIcon(string &icon, int64_t id)
{
cJSON *appNode = cJSON_GetObjectItem(root_, "app");
if (!appNode || !cJSON_IsObject(appNode)) {
@@ -141,7 +141,7 @@ bool ConfigParser::SetAppIcon(string &icon, int32_t id)
return true;
}
bool ConfigParser::SetAppLabel(string &label, int32_t id)
bool ConfigParser::SetAppLabel(string &label, int64_t id)
{
cJSON *appNode = cJSON_GetObjectItem(root_, "app");
if (!appNode || !cJSON_IsObject(appNode)) {
+1 -1
View File
@@ -273,7 +273,7 @@ bool ReferenceParser::ParseRefImpl(string &key, const map<string, ResType> &refs
smatch result;
if (regex_search(key, result, regex(ref.first))) {
string name = key.substr(result[0].str().length());
int32_t id = idWorker_.GetId(ref.second, name);
int64_t id = idWorker_.GetId(ref.second, name);
if (isSystem) {
id = idWorker_.GetSystemId(ref.second, name);
}
+1 -1
View File
@@ -355,7 +355,7 @@ string ResourceUtil::PaserKeyParam(const vector<KeyParam> &keyParams)
return result;
}
string ResourceUtil::DecToHexStr(const int32_t i)
string ResourceUtil::DecToHexStr(const uint32_t i)
{
stringstream ot;
string result;