静态告警修改和代码优化

Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
fangyunzhong
2022-09-24 11:16:08 +08:00
parent aa27bed3b8
commit c556922ae5
5 changed files with 23 additions and 7 deletions
+4
View File
@@ -34,6 +34,10 @@ public:
private:
bool Combine(const std::string &folderPath);
bool ScanResources(const std::string &resourcePath, const std::string &outputPath);
bool ScanSubResources(const FileEntry entry, const std::string &resourcePath,
const std::string &outputPath);
bool ScanSubLimitkeyResources(const FileEntry entry, const std::string &resourcePath,
const std::string &outputPath);
bool ScanIegalResources(const std::string &resourcePath, const std::string &outputPath);
bool ScanLimitKey(const std::unique_ptr<FileEntry> &entry, const std::string &limitKey,
const std::string outputPath);
+2 -3
View File
@@ -101,9 +101,8 @@ int32_t IncrementList::GetPriority(const string &filePath) const
bool IncrementList::ParseSegment(const string &filePath, vector<string> &segments) const
{
for (const auto &it : FileEntry::FilePath(filePath).GetSegments()) {
segments.push_back(it);
}
vector<string> segs = FileEntry::FilePath(filePath).GetSegments();
copy(segs.begin(), segs.end(), back_inserter(segments));
if (segments.size() >= (SEG_RESOURCE + 1) && segments[SEG_RESOURCE] != RESOURCES_DIR) {
cerr << "Error: '" << filePath << "' don't contain '" << RESOURCES_DIR << "'" << endl;
-2
View File
@@ -298,8 +298,6 @@ bool ReferenceParser::ParseRefImpl(string &key, const map<string, ResType> &refs
int32_t id = idWorker_.GetId(ref.second, name);
if (isSystem) {
id = idWorker_.GetSystemId(ref.second, name);
} else {
id = idWorker_.GetId(ref.second, name);
}
if (id < 0) {
cerr << "Error: ref '" << key << "' don't be defined." << endl;
+15
View File
@@ -135,6 +135,11 @@ bool ResourceAppend::ScanResources(const string &resourcePath, const string &out
return ScanSingleFile(resourcePath, outputPath);
}
return ScanSubResources(entry, resourcePath, outputPath);
}
bool ResourceAppend::ScanSubResources(const FileEntry entry, const string &resourcePath, const string &outputPath)
{
vector<KeyParam> keyParams;
if (KeyParser::Parse(entry.GetFilePath().GetFilename(), keyParams)) {
for (const auto &child : entry.GetChilds()) {
@@ -152,6 +157,12 @@ bool ResourceAppend::ScanResources(const string &resourcePath, const string &out
return ScanIegalResources(resourcePath, outputPath);
}
return ScanSubLimitkeyResources(entry, resourcePath, outputPath);
}
bool ResourceAppend::ScanSubLimitkeyResources(const FileEntry entry, const string &resourcePath,
const string &outputPath)
{
for (const auto &child : entry.GetChilds()) {
string limitKey = child->GetFilePath().GetFilename();
if (ResourceUtil::IsIgnoreFile(limitKey, child->IsFile())) {
@@ -526,6 +537,10 @@ bool ResourceAppend::LoadResourceItemFromMem(const char buffer[], int32_t length
return false;
}
if (!ResourceUtil::FileExist(filePathStr)) {
continue;
}
if (!ResourceUtil::CopyFleInner(filePathStr, outPath.Append(data).GetPath())) {
return false;
}
+2 -2
View File
@@ -92,14 +92,14 @@ uint32_t ResourcePack::InitModule()
});
if (it == moduleNames.end()) {
string buffer(" ");
for_each(moduleNames.begin(), moduleNames.end(), [&buffer](auto &iter) {
for_each(moduleNames.begin(), moduleNames.end(), [&buffer](const auto &iter) {
buffer.append(" " + iter + " ");
});
cerr << "Error: module name '" << moduleName_ << "' not in [" << buffer << "]" << endl;
return RESTOOL_ERROR;
}
int32_t startId = ((it - moduleNames.begin()) + 1) * 0x01000000;
startId = ((it - moduleNames.begin()) + 1) * 0x01000000;
if (startId >= 0x07000000) {
startId = startId + 0x01000000;
}