mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 09:14:48 -04:00
!212 修复读取resource.index文件时数据长度错误的问题
Merge pull request !212 from HanSY/fixupFA
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ public:
|
||||
std::vector<ResourceId> GetHeaderId() const;
|
||||
int64_t GetId(ResType resType, const std::string &name) const;
|
||||
int64_t GetSystemId(ResType resType, const std::string &name) const;
|
||||
int64_t LoadIdFromHap(const std::map<int64_t, std::vector<ResourceItem>> &items);
|
||||
int64_t LoadIdFromHap(std::map<int64_t, std::vector<ResourceItem>> &items);
|
||||
|
||||
private:
|
||||
int64_t GenerateAppId(ResType resType, const std::string &name);
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
const std::vector<std::string> SplitValue() const;
|
||||
bool IsArray() const;
|
||||
bool IsPair() const;
|
||||
void CheckData();
|
||||
|
||||
ResourceItem &operator=(const ResourceItem &other);
|
||||
private:
|
||||
|
||||
+4
-3
@@ -84,12 +84,13 @@ int64_t IdWorker::GetSystemId(ResType resType, const string &name) const
|
||||
return result->second.id;
|
||||
}
|
||||
|
||||
int64_t IdWorker::LoadIdFromHap(const map<int64_t, vector<ResourceItem>> &items)
|
||||
int64_t IdWorker::LoadIdFromHap(map<int64_t, vector<ResourceItem>> &items)
|
||||
{
|
||||
int64_t minId = 0xffffffff;
|
||||
int64_t maxId = 0x01000000;
|
||||
for (const auto &item : items) {
|
||||
for (const auto &resourceItem : item.second) {
|
||||
for (auto &item : items) {
|
||||
for (auto &resourceItem : item.second) {
|
||||
resourceItem.CheckData();
|
||||
ids_.emplace(make_pair(resourceItem.GetResType(), resourceItem.GetName()), item.first);
|
||||
}
|
||||
minId = min(minId, item.first);
|
||||
|
||||
@@ -160,6 +160,17 @@ const std::vector<std::string> ResourceItem::SplitValue() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ResourceItem::CheckData()
|
||||
{
|
||||
int8_t data[GetDataLength()];
|
||||
for (int i = 0; i < GetDataLength(); i++) {
|
||||
data[i] = GetData()[i];
|
||||
}
|
||||
if (data[GetDataLength() - 1] == '\0') {
|
||||
SetData(data, GetDataLength() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
ResourceItem &ResourceItem::operator=(const ResourceItem &other)
|
||||
{
|
||||
if (this == &other) {
|
||||
|
||||
@@ -510,9 +510,6 @@ bool ResourceTable::ReadDataRecordStart(basic_istream<char> &in, RecordItem &rec
|
||||
const vector<KeyParam> &keyparams = limitKeys.find(datas.find(offset)->second.second)->second;
|
||||
ResourceItem resourceitem(filename, keyparams, g_resTypeMap.find(record.resType)->second);
|
||||
resourceitem.SetLimitKey(ResourceUtil::PaserKeyParam(keyparams));
|
||||
if (values[value_size - 1] == '\0') {
|
||||
value_size--;
|
||||
}
|
||||
resourceitem.SetData(values, value_size);
|
||||
resourceitem.MarkCoverable();
|
||||
resInfos[record.id].push_back(resourceitem);
|
||||
|
||||
Reference in New Issue
Block a user