1, 删除多余日志

2,修复不能引用系统资源缺陷
3,配置文件中startWindowIcon,startWindowBackground,resource,extra 标签资源引用替换成资源ID

Signed-off-by: chencheng31 <chencheng8@huawei.com>
This commit is contained in:
chencheng31
2022-04-19 14:34:56 +08:00
parent e947ee7547
commit 471fc07eae
6 changed files with 15 additions and 12 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ const static std::string ID_DEFINED_FILE = "id_defined.json";
const static std::string RESOURCE_INDEX_FILE = "resources.index";
const static std::string SEPARATOR = "/";
const static int32_t VERSION_MAX_LEN = 128;
static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 2.007" };
static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 2.008" };
const static int32_t TAG_LEN = 4;
enum class KeyType {
+5 -1
View File
@@ -34,7 +34,11 @@ const map<string, string> ConfigParser::JSON_STRING_IDS = {
{ "label", "^\\$string:" },
{ "description", "^\\$string:" },
{ "theme", "^\\$theme:" },
{ "reason", "^\\$string:" }
{ "reason", "^\\$string:" },
{ "startWindowIcon", "^\\$media:" },
{ "startWindowBackground", "^\\$color:"},
{ "resource", "^\\$[a-z]+:" },
{ "extra", "^\\$[a-z]+:" }
};
const map<string, string> ConfigParser::JSON_ARRAY_IDS = {
+1 -2
View File
@@ -65,7 +65,6 @@ const vector<unique_ptr<FileEntry>> FileEntry::GetChilds() const
filePath = filePath_.GetPath() + SEPARATE + filename;
unique_ptr<FileEntry> f = make_unique<FileEntry>(filePath);
cout << filePath << endl;
f->Init();
children.push_back(move(f));
}
@@ -223,7 +222,7 @@ bool FileEntry::CreateDirsInner(const string &path, string::size_type offset)
string::size_type pos = path.find_first_of(SEPARATE.front(), offset);
if (pos == string::npos) {
#if _WIN32
return mkdir(path.c_str());
return mkdir(path.c_str()) == 0;
#else
return mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0;
#endif
-1
View File
@@ -68,7 +68,6 @@ uint32_t IResourceCompiler::Compile(const vector<DirectoryInfo> &directoryInfos)
return a.filePath < b.filePath;
});
for (const auto &fileInfo : fileInfos) {
cout << "compile " << fileInfo.filePath << endl;
if (CompileSingleFile(fileInfo) != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
+7 -7
View File
@@ -169,7 +169,7 @@ bool JsonCompiler::HandleBoolean(const Json::Value &objectNode, ResourceItem &re
{
Json::Value valueNode = objectNode[TAG_VALUE];
if (valueNode.isString()) {
regex ref("^\\$boolean:.*");
regex ref("^\\$(ohos:)?boolean:.*");
if (!regex_match(valueNode.asString(), ref)) {
cerr << "Error: '" << valueNode.asString() << "' only refer '$boolean:xxx',";
cerr << resourceItem.GetFilePath() << endl;
@@ -290,17 +290,17 @@ bool JsonCompiler::CheckJsonStringValue(const Json::Value &valueNode, const Reso
}
const map<ResType, string> REFS = {
{ ResType::STRING, "$string:" },
{ ResType::STRARRAY, "$string:" },
{ ResType::COLOR, "$color:" },
{ ResType::FLOAT, "$float:" }
{ ResType::STRING, "\\$(ohos:)?string:" },
{ ResType::STRARRAY, "\\$(ohos:)?string:" },
{ ResType::COLOR, "\\$(ohos:)?color:" },
{ ResType::FLOAT, "\\$(ohos:)?float:" }
};
string value = valueNode.asString();
ResType type = resourceItem.GetResType();
regex ref("^\\$.+:");
smatch result;
if (regex_search(value, result, ref) && result[0] != REFS.at(type)) {
if (regex_search(value, result, ref) && !regex_match(result[0].str(), regex(REFS.at(type)))) {
cerr << "Error: '" << value << "' only refer '"<< REFS.at(type) << "xxx',";
cerr << resourceItem.GetFilePath() << endl;
return false;
@@ -311,7 +311,7 @@ bool JsonCompiler::CheckJsonStringValue(const Json::Value &valueNode, const Reso
bool JsonCompiler::CheckJsonIntegerValue(const Json::Value &valueNode, const ResourceItem &resourceItem) const
{
if (valueNode.isString()) {
regex ref("^\\$integer:.*");
regex ref("^\\$(ohos:)?integer:.*");
if (!regex_match(valueNode.asString(), ref)) {
cerr << "Error: '" << valueNode.asString() << "' only refer '$integer:xxx',";
cerr << resourceItem.GetFilePath() << endl;
+1
View File
@@ -236,6 +236,7 @@ bool ResourceUtil::CreateDirs(const string &filePath)
if (!FileEntry::CreateDirs(filePath)) {
cerr << "Error: create dir fail '" << filePath << "'" << endl;
return false;
}
return true;
}