diff --git a/include/resource_data.h b/include/resource_data.h index 7487426..92c3fee 100644 --- a/include/resource_data.h +++ b/include/resource_data.h @@ -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 { diff --git a/src/config_parser.cpp b/src/config_parser.cpp index b5a825c..5879e98 100644 --- a/src/config_parser.cpp +++ b/src/config_parser.cpp @@ -34,7 +34,11 @@ const map 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 ConfigParser::JSON_ARRAY_IDS = { diff --git a/src/file_entry.cpp b/src/file_entry.cpp index e51c3e1..e74ae67 100644 --- a/src/file_entry.cpp +++ b/src/file_entry.cpp @@ -65,7 +65,6 @@ const vector> FileEntry::GetChilds() const filePath = filePath_.GetPath() + SEPARATE + filename; unique_ptr f = make_unique(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 diff --git a/src/i_resource_compiler.cpp b/src/i_resource_compiler.cpp index 0b3e53d..b3c598c 100644 --- a/src/i_resource_compiler.cpp +++ b/src/i_resource_compiler.cpp @@ -68,7 +68,6 @@ uint32_t IResourceCompiler::Compile(const vector &directoryInfos) return a.filePath < b.filePath; }); for (const auto &fileInfo : fileInfos) { - cout << "compile " << fileInfo.filePath << endl; if (CompileSingleFile(fileInfo) != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } diff --git a/src/json_compiler.cpp b/src/json_compiler.cpp index 023893b..9015f22 100644 --- a/src/json_compiler.cpp +++ b/src/json_compiler.cpp @@ -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 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; diff --git a/src/resource_util.cpp b/src/resource_util.cpp index deb0815..f47c1db 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -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; }