diff --git a/include/resource_data.h b/include/resource_data.h index 66c1805..5fe7062 100644 --- a/include/resource_data.h +++ b/include/resource_data.h @@ -31,6 +31,7 @@ const static std::string RAW_FILE_DIR = "rawfile"; 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 std::string NEW_LINE_PATH = "\r\nat "; const static int32_t VERSION_MAX_LEN = 128; static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 2.010" }; const static int32_t TAG_LEN = 4; diff --git a/include/restool_errors.h b/include/restool_errors.h index 372dad3..3fc9a2c 100644 --- a/include/restool_errors.h +++ b/include/restool_errors.h @@ -17,6 +17,7 @@ #define OHOS_RESTOOL_ERRORS_H #include +#include "resource_data.h" namespace OHOS { namespace Global { diff --git a/src/append_compiler.cpp b/src/append_compiler.cpp index eba4b54..f23a772 100644 --- a/src/append_compiler.cpp +++ b/src/append_compiler.cpp @@ -33,7 +33,7 @@ uint32_t AppendCompiler::CompileSingleFile(const FileInfo &fileInfo) string data = fileInfo.filePath; if (!resourceItem.SetData(reinterpret_cast(data.c_str()), data.length())) { - cerr << "Error: resource item set data fail, " << fileInfo.filePath << endl; + cerr << "Error: resource item set data fail, data: " << data << NEW_LINE_PATH << fileInfo.filePath << endl; return RESTOOL_ERROR; } diff --git a/src/config_parser.cpp b/src/config_parser.cpp index ba7a62b..c405823 100644 --- a/src/config_parser.cpp +++ b/src/config_parser.cpp @@ -69,7 +69,7 @@ uint32_t ConfigParser::Init() } if (!rootNode_.isObject()) { - cerr << "Error: root node not obeject in " << filePath_ << endl; + cerr << "Error: root node not obeject." << NEW_LINE_PATH << filePath_ << endl; return RESTOOL_ERROR; } @@ -114,11 +114,11 @@ uint32_t ConfigParser::Save(const string &filePath) const bool ConfigParser::ParseModule(Json::Value &moduleNode) { if (!moduleNode.isObject()) { - cerr << "Error: 'module' not object in " << filePath_ << endl; + cerr << "Error: 'module' not object." << NEW_LINE_PATH << filePath_ << endl; return false; } if (moduleNode.empty()) { - cerr << "Error: 'module' empty in " << filePath_ << endl; + cerr << "Error: 'module' empty." << NEW_LINE_PATH << filePath_ << endl; return false; } @@ -134,7 +134,7 @@ bool ConfigParser::ParseModule(Json::Value &moduleNode) } if (moduleName_.empty()) { - cerr << "Error: 'name' don't found in 'module', " << filePath_ << endl; + cerr << "Error: 'name' don't found in 'module'." << NEW_LINE_PATH << filePath_ << endl; return false; } @@ -147,11 +147,11 @@ bool ConfigParser::ParseModule(Json::Value &moduleNode) bool ConfigParser::ParseDistro(Json::Value &distroNode) { if (!distroNode.isObject()) { - cerr << "Error: 'distro' not object in " << filePath_ << endl; + cerr << "Error: 'distro' not object." << NEW_LINE_PATH << filePath_ << endl; return false; } if (distroNode.empty()) { - cerr << "Error: 'distro' empty in " << filePath_ << endl; + cerr << "Error: 'distro' empty." << NEW_LINE_PATH << filePath_ << endl; return false; } @@ -160,7 +160,7 @@ bool ConfigParser::ParseDistro(Json::Value &distroNode) } if (moduleName_.empty()) { - cerr << "Error: 'moduleName' don't found in 'distro', " << filePath_ << endl; + cerr << "Error: 'moduleName' don't found in 'distro'." << NEW_LINE_PATH << filePath_ << endl; return false; } @@ -201,13 +201,13 @@ bool ConfigParser::ParseJsonArrayRef(Json::Value &parent, const string &key, Jso Json::Value array(Json::arrayValue); for (Json::ArrayIndex index = 0; index < size; index++) { if (!node[index].isString()) { - cerr << "Error: '" << key << "' invalid value. " << filePath_ << endl; + cerr << "Error: '" << key << "' invalid value." << NEW_LINE_PATH << filePath_ << endl; return false; } string value = node[index].asString(); bool update = false; if (!GetRefIdFromString(value, update, JSON_ARRAY_IDS.at(key))) { - cerr << "Error: '" << key << "' value " << node[index] << " invalid. " << filePath_ << endl; + cerr << "Error: '" << key << "' value " << node[index] << " invalid." << NEW_LINE_PATH << filePath_ << endl; return false; } if (update) { @@ -227,7 +227,7 @@ bool ConfigParser::ParseJsonStringRef(Json::Value &parent, const string &key, Js string value = node.asString(); bool update = false; if (!GetRefIdFromString(value, update, JSON_STRING_IDS.at(key))) { - cerr << "Error: '" << key << "' value " << node << " invalid value. " << filePath_ << endl; + cerr << "Error: '" << key << "' value " << node << " invalid value." << NEW_LINE_PATH << filePath_ << endl; return false; } if (update) { @@ -259,7 +259,7 @@ bool ConfigParser::ParseModuleType(const string &type) { const auto &result = MODULE_TYPES.find(type); if (result == MODULE_TYPES.end()) { - cerr << "Error: moduleType='" << type << "' invalid value in " << filePath_ << endl; + cerr << "Error: moduleType='" << type << "' invalid value." << NEW_LINE_PATH << filePath_ << endl; return false; } moduleType_ = result->second; diff --git a/src/file_entry.cpp b/src/file_entry.cpp index 26d844d..c335b1b 100644 --- a/src/file_entry.cpp +++ b/src/file_entry.cpp @@ -14,11 +14,12 @@ */ #include "file_entry.h" -#include -#include +#include +#include #include "dirent.h" #include "sys/stat.h" #include "unistd.h" +#include #ifdef _WIN32 #include "windows.h" #include "shlwapi.h" @@ -146,13 +147,14 @@ bool FileEntry::CopyFileInner(const string &src, const string &dst) { #ifdef _WIN32 if (!CopyFile(src.c_str(), dst.c_str(), false)) { + cerr << "Error: CopyFile '" << src << "' to '" << dst << "' failed." << endl; return false; } #else ifstream in(src, ios::binary); ofstream out(dst, ios::binary); if (!in || !out) { - cerr << "Error: CopyFile '" << src << "' or '" << dst << "' open fail." << endl; + cerr << "Error: open failed '" << src << "' or '" << dst << "'." << endl; return false; } out << in.rdbuf(); @@ -282,7 +284,8 @@ bool FileEntry::RemoveAllDirInner(const FileEntry &entry) if (entry.IsFile()) { bool result = remove(entry.GetFilePath().GetPath().c_str()) == 0; if (!result) { - cerr << "Error: " << entry.GetFilePath().GetPath() << "remove fail !" << endl; + cerr << "Error: remove failed '" << entry.GetFilePath().GetPath(); + cerr << "', reason: " << strerror(errno) << endl; return false; } return true; diff --git a/src/generic_compiler.cpp b/src/generic_compiler.cpp index 3dd5e26..3e55c93 100644 --- a/src/generic_compiler.cpp +++ b/src/generic_compiler.cpp @@ -60,7 +60,7 @@ bool GenericCompiler::PostFile(const FileInfo &fileInfo) data = moduleName_ + SEPARATOR + RESOURCES_DIR + SEPARATOR + \ fileInfo.limitKey + SEPARATOR + fileInfo.fileCluster + SEPARATOR + data; if (!resourceItem.SetData(reinterpret_cast(data.c_str()), data.length())) { - cerr << "Error: resource item set data fail, " << fileInfo.filePath << endl; + cerr << "Error: resource item set data fail, data: " << data << NEW_LINE_PATH << fileInfo.filePath << endl; return false; } return MergeResourceItem(resourceItem); diff --git a/src/header.cpp b/src/header.cpp index 5a99bb5..73f1c06 100644 --- a/src/header.cpp +++ b/src/header.cpp @@ -53,7 +53,7 @@ uint32_t Header::Create(HandleHeaderTail headerHandler, HandleBody bodyHandler, ofstream out(outputPath_, ofstream::out | ofstream::binary); if (!out.is_open()) { - cerr << "Error: open fail '" << outputPath_ << "'" << endl; + cerr << "Error: open failed '" << outputPath_ << "', reason: " << strerror(errno) << endl; return RESTOOL_ERROR; } diff --git a/src/i_resource_compiler.cpp b/src/i_resource_compiler.cpp index a9f26fd..044fde9 100644 --- a/src/i_resource_compiler.cpp +++ b/src/i_resource_compiler.cpp @@ -178,7 +178,7 @@ bool IResourceCompiler::MergeResourceItem(const ResourceItem &resourceItem) } string idName = ResourceUtil::GetIdName(resourceItem.GetName(), resourceItem.GetResType()); if (!IdWorker::GetInstance().IsValidName(idName)) { - cerr << "Error: in " << resourceItem.GetFilePath() << endl; + cerr << "Error: invalid idName '" << idName << "'."<< NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } auto item = nameInfos_.find(make_pair(resourceItem.GetResType(), idName)); @@ -191,8 +191,8 @@ bool IResourceCompiler::MergeResourceItem(const ResourceItem &resourceItem) return resourceItem.GetLimitKey() == iter.GetLimitKey(); }); if (ret != item->second.end()) { - cerr << "Error: resource '" << idName << "' first declared in " << ret->GetFilePath(); - cerr << ", but declare again in " << resourceItem.GetFilePath() << endl; + cerr << "Error: resource '" << idName << "' first declared." << NEW_LINE_PATH << ret->GetFilePath() << endl; + cerr << "but declare again." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } diff --git a/src/increment_index.cpp b/src/increment_index.cpp index 27a7c58..34c73b2 100644 --- a/src/increment_index.cpp +++ b/src/increment_index.cpp @@ -67,12 +67,12 @@ bool IncrementIndex::Load(map> &items) const auto headerInfo = indexJson["header"]; if (headerInfo.empty() || !headerInfo.isObject()) { - cerr << "Error: " << indexPath_ << " header info." << endl; + cerr << "Error: header info." << NEW_LINE_PATH << indexPath_ << endl; return true; } auto folderInfo = headerInfo["folder"]; if (folderInfo.empty() || !folderInfo.isArray()) { - cerr << "Error: " << indexPath_ << " folder info." << endl; + cerr << "Error: folder info." << NEW_LINE_PATH << indexPath_ << endl; return false; } if (folder_.size() != folderInfo.size()) { @@ -102,22 +102,22 @@ void IncrementIndex::SetSkipPaths(const vector &skipPaths) bool IncrementIndex::LoadIndex(const Json::Value &indexInfo, map> &items) const { if (indexInfo.empty() || !indexInfo.isObject()) { - cerr << "Error: " << indexPath_ << " index info." << endl; + cerr << "Error: index info." << NEW_LINE_PATH << indexPath_ << endl; return false; } for (const auto &idMember : indexInfo.getMemberNames()) { int32_t id = strtol(idMember.c_str(), nullptr, 10); if (id < 0) { - cerr << "Error: " << indexPath_ << " '" << idMember << "' not integer string." << endl; + cerr << "Error: '" << idMember << "' not integer string." << NEW_LINE_PATH << indexPath_ << endl; return false; } if (items.count(id) != 0) { - cerr << "Error: " << indexPath_ << " '" << idMember << "' duplicated." << endl; + cerr << "Error: '" << idMember << "' duplicated." << NEW_LINE_PATH << indexPath_ << endl; return false; } if (!indexInfo[idMember].isObject()) { - cerr << "Error: " << indexPath_ << " '" << idMember << "' not object." << endl; + cerr << "Error: '" << idMember << "' not object." << NEW_LINE_PATH << indexPath_ << endl; return false; } for (const auto &pathMember : indexInfo[idMember].getMemberNames()) { @@ -126,12 +126,13 @@ bool IncrementIndex::LoadIndex(const Json::Value &indexInfo, map keyParams; @@ -193,20 +194,21 @@ bool IncrementIndex::PushResourceItem(const ResourceItem &resourceItem, int32_t const auto &first = items[id].begin(); if (resourceItem.GetName() != first->GetName()) { - cerr << "Error: " << indexPath_ << " '" << resourceItem.GetName(); - cerr << "', expect '" << first->GetName() << "'"<< endl; + cerr << "Error: '" << resourceItem.GetName() << "', expect '" << first->GetName() << "'."; + cerr << NEW_LINE_PATH << indexPath_ <GetResType()) { - cerr << "Error: " << indexPath_ << " '" << ResourceUtil::ResTypeToString(resourceItem.GetResType()); - cerr << "', expect '" << ResourceUtil::ResTypeToString(first->GetResType()) << "'"<< endl; + cerr << "Error: '" << ResourceUtil::ResTypeToString(resourceItem.GetResType()); + cerr << "', expect '" << ResourceUtil::ResTypeToString(first->GetResType()) << "'."; + cerr << NEW_LINE_PATH << indexPath_ << endl; return false; } auto result = find_if(items[id].begin(), items[id].end(), [&resourceItem](const auto &iter) { return resourceItem.GetLimitKey() == iter.GetLimitKey(); }); if (result != items[id].end()) { - cerr << "Error: " << indexPath_ << " '" << resourceItem.GetLimitKey() << "' conflict." << endl; + cerr << "Error: '" << resourceItem.GetLimitKey() << "' conflict." << NEW_LINE_PATH << indexPath_ << endl; return false; } items[id].push_back(resourceItem); diff --git a/src/increment_list.cpp b/src/increment_list.cpp index 839b104..1b24416 100644 --- a/src/increment_list.cpp +++ b/src/increment_list.cpp @@ -48,7 +48,7 @@ bool IncrementList::GetFromPath(const string &filePath, FileIncrement &info) con { int32_t priority = GetPriority(filePath); if (priority < 0) { - cerr << "Error: " << RESTOOL_LIST_FILE << " '" << filePath << "' invalid." << endl; + cerr << "Error: '" << RESTOOL_LIST_FILE << "' invalid." << NEW_LINE_PATH << filePath << endl; return false; } info.rootPath = folder_[priority]; @@ -67,14 +67,14 @@ bool IncrementList::GetFromPath(const string &filePath, FileIncrement &info) con return true; } if (!KeyParser::Parse(info.limitKey, info.keyParams)) { - cerr << "Error: '" << filePath << "' '" << info.limitKey << "' invalid limit key." << endl; + cerr << "Error: '" << info.limitKey << "' invalid limit key." << NEW_LINE_PATH << filePath << endl; return false; } info.fileCluster = segments[SEG_FILE_CLUSTER]; info.dirType = ResourceUtil::GetResTypeByDir(info.fileCluster); if (info.dirType == ResType::INVALID_RES_TYPE) { - cerr << "Error: '" << filePath << "' '" << info.fileCluster << "' invalid ResType." << endl; + cerr << "Error: '" << info.fileCluster << "' invalid ResType." << NEW_LINE_PATH << filePath << endl; return false; } info.filename = segments[SEG_FILE_NAME]; @@ -105,7 +105,7 @@ bool IncrementList::ParseSegment(const string &filePath, vector &segment 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; + cerr << "Error: don't contain '" << RESOURCES_DIR << "'." << NEW_LINE_PATH << filePath << endl; return false; } @@ -114,7 +114,7 @@ bool IncrementList::ParseSegment(const string &filePath, vector &segment } if (segments.size() != SEG_MAX) { - cerr << "Error: '" << filePath << "' segments != " << SEG_MAX << endl; + cerr << "Error: segments != " << SEG_MAX << NEW_LINE_PATH << filePath << endl; return false; } return true; diff --git a/src/increment_manager.cpp b/src/increment_manager.cpp index 306dab8..d28466b 100644 --- a/src/increment_manager.cpp +++ b/src/increment_manager.cpp @@ -174,7 +174,7 @@ bool IncrementManager::LoadIdJson() } if (!root.isObject()) { - cerr << "Error: '" << idJsonPath << "' invalid, not object." << endl; + cerr << "Error: invalid, not object." << NEW_LINE_PATH << idJsonPath << endl; return false; } @@ -182,28 +182,29 @@ bool IncrementManager::LoadIdJson() for (const auto &member : root.getMemberNames()) { int32_t id = strtol(member.c_str(), nullptr, 10); if (id < 0) { - cerr << "Error: '" << idJsonPath << "' invalid '" << member << "'" << endl; + cerr << "Error: invalid '" << member << "'." << NEW_LINE_PATH << idJsonPath << endl; return false; } const auto &node = root[member]; if (!node.isObject()) { - cerr << "Error: '" << idJsonPath << "' '" << member << "' not object." << endl; + cerr << "Error: '" << member << "' not object." << NEW_LINE_PATH << idJsonPath << endl; return false; } if (!node["name"].isString()) { - cerr << "Error: '" << idJsonPath << "' '" << member << "' name not string." << endl; + cerr << "Error: '" << member << "' name not string." << NEW_LINE_PATH << idJsonPath << endl; return false; } string name = node["name"].asString(); if (!node["type"].isString()) { - cerr << "Error: '" << idJsonPath << "' '" << member << "' type not string." << endl; + cerr << "Error: '" << member << "' type not string." << NEW_LINE_PATH << idJsonPath << endl; return false; } ResType resType = ResourceUtil::GetResTypeFromString(node["type"].asString()); if (resType == ResType::INVALID_RES_TYPE) { - cerr << "Error: '" << idJsonPath << "' '" << member << "' '" << node["type"] << "' invalid." << endl; + cerr << "Error: '" << member << "' '" << node["type"] << "' invalid."; + cerr << NEW_LINE_PATH << idJsonPath << endl; return false; } if (!idWorker.PushCache(resType, name, id)) { @@ -267,7 +268,8 @@ bool IncrementManager::ClearSolidXml() const } if (remove(entry->GetFilePath().GetPath().c_str()) != 0) { - cerr << "Error: remove '" << entry->GetFilePath().GetPath() << "' fail." << endl; + cerr << "Error: remove failed '" << entry->GetFilePath().GetPath(); + cerr << "', reason: " << strerror(errno) << endl; return false; } } diff --git a/src/json_compiler.cpp b/src/json_compiler.cpp index df96f8e..62cb683 100644 --- a/src/json_compiler.cpp +++ b/src/json_compiler.cpp @@ -52,19 +52,19 @@ uint32_t JsonCompiler::CompileSingleFile(const FileInfo &fileInfo) } if (!root.isObject()) { - cerr << "Error: root node must object," << fileInfo.filePath << endl; + cerr << "Error: root node must object." << NEW_LINE_PATH << fileInfo.filePath << endl; return RESTOOL_ERROR; } if (root.getMemberNames().size() != 1) { - cerr << "Error: root node must only one member," << fileInfo.filePath << endl; + cerr << "Error: root node must only one member." << NEW_LINE_PATH << fileInfo.filePath << endl; return RESTOOL_ERROR; } string tag = root.getMemberNames()[0]; auto ret = g_contentClusterMap.find(tag); if (ret == g_contentClusterMap.end()) { - cerr << "Error: invalid tag name '" << tag << "'," << fileInfo.filePath << endl; + cerr << "Error: invalid tag name '" << tag << "'." << NEW_LINE_PATH << fileInfo.filePath << endl; return RESTOOL_ERROR; } @@ -95,20 +95,20 @@ void JsonCompiler::InitParser() bool JsonCompiler::ParseJsonArrayLevel(const Json::Value &arrayNode, const FileInfo &fileInfo) { if (!arrayNode.isArray()) { - cerr << "Error: '" << ResourceUtil::ResTypeToString(fileInfo.fileType) << "' must be array,"; - cerr << fileInfo.filePath << endl; + cerr << "Error: '" << ResourceUtil::ResTypeToString(fileInfo.fileType) << "' must be array."; + cerr << NEW_LINE_PATH << fileInfo.filePath << endl; return false; } if (arrayNode.empty()) { - cerr << "Error: '" << ResourceUtil::ResTypeToString(fileInfo.fileType) << "' empty,"; - cerr << fileInfo.filePath << endl; + cerr << "Error: '" << ResourceUtil::ResTypeToString(fileInfo.fileType) << "' empty."; + cerr << NEW_LINE_PATH << fileInfo.filePath << endl; return false; } for (Json::ArrayIndex index = 0; index < arrayNode.size(); index++) { if (!arrayNode[index].isObject()) { - cerr << "Error: the seq=" << index << " item must be object," << fileInfo.filePath << endl; + cerr << "Error: the seq=" << index << " item must be object." << NEW_LINE_PATH << fileInfo.filePath << endl; return false; } if (!ParseJsonObjectLevel(arrayNode[index], fileInfo)) { @@ -122,12 +122,12 @@ bool JsonCompiler::ParseJsonObjectLevel(const Json::Value &objectNode, const Fil { auto nameNode = objectNode[TAG_NAME]; if (nameNode.empty()) { - cerr << "Error: name empty," << fileInfo.filePath << endl; + cerr << "Error: name empty." << NEW_LINE_PATH << fileInfo.filePath << endl; return false; } if (!nameNode.isString()) { - cerr << "Error: name must string," << fileInfo.filePath << endl; + cerr << "Error: name must string." << NEW_LINE_PATH << fileInfo.filePath << endl; return false; } @@ -171,12 +171,13 @@ bool JsonCompiler::HandleBoolean(const Json::Value &objectNode, ResourceItem &re if (valueNode.isString()) { regex ref("^\\$(ohos:)?boolean:.*"); if (!regex_match(valueNode.asString(), ref)) { - cerr << "Error: '" << valueNode.asString() << "' only refer '$boolean:xxx',"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << valueNode.asString() << "' only refer '$boolean:xxx'."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } } else if (!valueNode.isBool()) { - cerr << "Error: '" << resourceItem.GetName() << "' value not boolean," << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << resourceItem.GetName() << "' value not boolean."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return PushString(valueNode.asString(), resourceItem); @@ -198,8 +199,8 @@ bool JsonCompiler::HandleStringArray(const Json::Value &objectNode, ResourceItem return ParseValueArray(objectNode, resourceItem, extra, [this](const Json::Value &arrayItem, const ResourceItem &resourceItem, vector &values) -> bool { if (!arrayItem.isObject()) { - cerr << "Error: '" << resourceItem.GetName() << "' value array item not object,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << resourceItem.GetName() << "' value array item not object."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } auto value = arrayItem[TAG_VALUE]; @@ -253,7 +254,7 @@ bool JsonCompiler::HandlePlural(const Json::Value &objectNode, ResourceItem &res string quantityValue = arrayItem[TAG_QUANTITY].asString(); if (find(attrs.begin(), attrs.end(), quantityValue) != attrs.end()) { cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity '" << quantityValue; - cerr << "' duplicated," << resourceItem.GetFilePath() << endl; + cerr << "' duplicated." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } attrs.push_back(quantityValue); @@ -265,8 +266,8 @@ bool JsonCompiler::HandlePlural(const Json::Value &objectNode, ResourceItem &res return false; } if (find(attrs.begin(), attrs.end(), "other") == attrs.end()) { - cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity must contains 'other',"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity must contains 'other'."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return true; @@ -275,8 +276,8 @@ bool JsonCompiler::HandlePlural(const Json::Value &objectNode, ResourceItem &res bool JsonCompiler::PushString(const string &value, ResourceItem &resourceItem) const { if (!resourceItem.SetData(reinterpret_cast(value.c_str()), value.length())) { - cerr << "Error: resourceItem setdata fail,'" << resourceItem.GetName() << "',"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: resourceItem setdata fail,'" << resourceItem.GetName() << "'."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return true; @@ -285,7 +286,8 @@ bool JsonCompiler::PushString(const string &value, ResourceItem &resourceItem) c bool JsonCompiler::CheckJsonStringValue(const Json::Value &valueNode, const ResourceItem &resourceItem) const { if (!valueNode.isString()) { - cerr << "Error: '" << resourceItem.GetName() << "' value not string," << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << resourceItem.GetName() << "' value not string."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } @@ -299,15 +301,16 @@ bool JsonCompiler::CheckJsonStringValue(const Json::Value &valueNode, const Reso string value = valueNode.asString(); ResType type = resourceItem.GetResType(); if (type == ResType::COLOR && !CheckColorValue(value.c_str())) { - string error = "invaild color '" + value + "', in " + resourceItem.GetFilePath(); - cerr << "Error: " << error << endl; + string error = "invaild color value '" + value + \ + "', only support refer '$color:xxx' or '#rgb','#argb','#rrggbb','aarrggbb'."; + cerr << "Error: " << error << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } regex ref("^\\$.+:"); smatch result; 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; + cerr << "Error: '" << value << "', only refer '"<< REFS.at(type) << "xxx'."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return true; @@ -318,12 +321,13 @@ bool JsonCompiler::CheckJsonIntegerValue(const Json::Value &valueNode, const Res if (valueNode.isString()) { regex ref("^\\$(ohos:)?integer:.*"); if (!regex_match(valueNode.asString(), ref)) { - cerr << "Error: '" << valueNode.asString() << "' only refer '$integer:xxx',"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << valueNode.asString() << "', only refer '$integer:xxx'."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } } else if (!valueNode.isInt()) { - cerr << "Error: '" << resourceItem.GetName() << "' value not integer," << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << resourceItem.GetName() << "' value not integer."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return true; @@ -334,12 +338,14 @@ bool JsonCompiler::ParseValueArray(const Json::Value &objectNode, ResourceItem & { Json::Value arrayNode = objectNode[TAG_VALUE]; if (!arrayNode.isArray()) { - cerr << "Error: '" << resourceItem.GetName() << "' value not array," << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << resourceItem.GetName() << "' value not array."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } if (arrayNode.empty()) { - cerr << "Error: '" << resourceItem.GetName() << "' value empty," << resourceItem.GetFilePath() << endl; + cerr << "Error: '" << resourceItem.GetName() << "' value empty."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } @@ -357,7 +363,8 @@ bool JsonCompiler::ParseValueArray(const Json::Value &objectNode, ResourceItem & string data = ResourceUtil::ComposeStrings(contents); if (data.empty()) { - cerr << "Error: '" << resourceItem.GetName() << "' array too large,"<< resourceItem.GetFilePath() << endl; + cerr << "Error: '" << resourceItem.GetName() << "' array too large."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return PushString(data, resourceItem); @@ -370,13 +377,13 @@ bool JsonCompiler::ParseParent(const Json::Value &objectNode, const ResourceItem string type = ResourceUtil::ResTypeToString(resourceItem.GetResType()); if (!parent.isNull()) { if (!parent.isString()) { - cerr << "Error: " << type << " '" << resourceItem.GetName() << "' parent not string,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: " << type << " '" << resourceItem.GetName() << "' parent not string."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } if (parent.empty()) { - cerr << "Error: " << type << " '"<< resourceItem.GetName() << "' parent empty,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: " << type << " '"<< resourceItem.GetName() << "' parent empty."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } string parentValue = parent.asString(); @@ -395,19 +402,19 @@ bool JsonCompiler::ParseAttribute(const Json::Value &arrayItem, const ResourceIt { string type = ResourceUtil::ResTypeToString(resourceItem.GetResType()); if (!arrayItem.isObject()) { - cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute not object,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute not object."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } auto name = arrayItem[TAG_NAME]; if (name.empty()) { - cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute name empty,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute name empty."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } if (!name.isString()) { - cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute name not string,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute name not string."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } values.push_back(name.asString()); @@ -415,12 +422,12 @@ bool JsonCompiler::ParseAttribute(const Json::Value &arrayItem, const ResourceIt auto value = arrayItem[TAG_VALUE]; if (value.isNull()) { cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute '" << name.asString(); - cerr << "' value empty," << resourceItem.GetFilePath() << endl; + cerr << "' value empty." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } if (!value.isString()) { cerr << "Error: " << type << " '" << resourceItem.GetName() << "' attribute '" << name.asString(); - cerr << "' value not string," << resourceItem.GetFilePath() << endl; + cerr << "' value not string." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } values.push_back(value.asString()); @@ -430,19 +437,19 @@ bool JsonCompiler::ParseAttribute(const Json::Value &arrayItem, const ResourceIt bool JsonCompiler::CheckPluralValue(const Json::Value &arrayItem, const ResourceItem &resourceItem) const { if (!arrayItem.isObject()) { - cerr << "Error: Plural '" << resourceItem.GetName() << "' array item not object,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: Plural '" << resourceItem.GetName() << "' array item not object."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } auto quantity = arrayItem[TAG_QUANTITY]; if (quantity.empty()) { - cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity empty,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity empty."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } if (!quantity.isString()) { - cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity not string,"; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity not string."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } string quantityValue = quantity.asString(); @@ -452,19 +459,19 @@ bool JsonCompiler::CheckPluralValue(const Json::Value &arrayItem, const Resource buffer.append(iter).append(" "); }); cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity '" << quantityValue; - cerr << "' not in [" << buffer << "]," << resourceItem.GetFilePath() << endl; + cerr << "' not in [" << buffer << "]." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } auto value = arrayItem[TAG_VALUE]; if (value.isNull()) { cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity '" << quantityValue; - cerr << "' value empty" << resourceItem.GetFilePath() << endl; + cerr << "' value empty." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } if (!value.isString()) { cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity '" << quantityValue; - cerr << "' value not string" << resourceItem.GetFilePath() << endl; + cerr << "' value not string." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return true; diff --git a/src/reference_parser.cpp b/src/reference_parser.cpp index d3f17db..29b3168 100644 --- a/src/reference_parser.cpp +++ b/src/reference_parser.cpp @@ -182,7 +182,7 @@ bool ReferenceParser::ParseRefResourceItem(ResourceItem &resourceItem) const if (IsStringOfResourceItem(resType)) { data = string(reinterpret_cast(resourceItem.GetData()), resourceItem.GetDataLength()); if (!ParseRefString(data, update)) { - cerr << "Error: in " << resourceItem.GetFilePath() << endl; + cerr << "Error: " << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } if (!update) { @@ -197,7 +197,8 @@ bool ReferenceParser::ParseRefResourceItem(ResourceItem &resourceItem) const } } if (update && !resourceItem.SetData(reinterpret_cast(data.c_str()), data.length())) { - cerr << "Error: set data fail '" << resourceItem.GetName() << "' in " << resourceItem.GetFilePath() << endl; + cerr << "Error: set data fail. name = '" << resourceItem.GetName() << "' data = '" << data << "'."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return true; @@ -208,15 +209,15 @@ bool ReferenceParser::ParseRefResourceItemData(const ResourceItem &resourceItem, data = string(reinterpret_cast(resourceItem.GetData()), resourceItem.GetDataLength()); vector contents = ResourceUtil::DecomposeStrings(data); if (contents.empty()) { - cerr << "Error: DecomposeStrings fail '" << resourceItem.GetName() << "' in "; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: DecomposeStrings fail. name = '" << resourceItem.GetName() << "' data = '" << data << "'."; + cerr << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } for (auto &content : contents) { bool flag = false; if (!ParseRefString(content, flag)) { - cerr << "Error: in " << resourceItem.GetFilePath() << endl; + cerr << "Error: " << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } update = (update || flag); @@ -228,8 +229,8 @@ bool ReferenceParser::ParseRefResourceItemData(const ResourceItem &resourceItem, data = ResourceUtil::ComposeStrings(contents); if (data.empty()) { - cerr << "Error: ComposeStrings fail '" << resourceItem.GetName() << "' in "; - cerr << resourceItem.GetFilePath() << endl; + cerr << "Error: ComposeStrings fail. name = '" << resourceItem.GetName(); + cerr << "' contents size is " << contents.size() << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; return false; } return true; diff --git a/src/resource_append.cpp b/src/resource_append.cpp index 8a066a4..18ad606 100644 --- a/src/resource_append.cpp +++ b/src/resource_append.cpp @@ -120,7 +120,7 @@ bool ResourceAppend::ScanResources(const string &resourcePath, const string &out if (!ResourceUtil::FileExist(resourcePath)) { string filePath = FileEntry::FilePath(outputPath).Append(ResourceUtil::GenerateHash(resourcePath)).GetPath(); if (remove(filePath.c_str()) != 0) { - cerr << "Error: remove '" << filePath << "'" << endl; + cerr << "Error: remove failed '" << filePath << "', reason: " << strerror(errno) << endl; return false; } return true; @@ -206,7 +206,8 @@ bool ResourceAppend::ScanLimitKey(const unique_ptr &entry, { vector keyParams; if (!KeyParser::Parse(limitKey, keyParams)) { - cerr << "Error: " << entry->GetFilePath().GetPath() << ",invalid limit key '" << limitKey << "'" << endl; + cerr << "Error: invalid limit key '" << limitKey << "'."; + cerr << NEW_LINE_PATH << entry->GetFilePath().GetPath() << endl; return false; } @@ -223,7 +224,7 @@ bool ResourceAppend::ScanLimitKey(const unique_ptr &entry, ResType resType = ResourceUtil::GetResTypeByDir(fileCuster); if (resType == ResType::INVALID_RES_TYPE) { - cerr << "Error: " << child->GetFilePath().GetPath() << " invalid" << endl; + cerr << "Error: invalid resType." << NEW_LINE_PATH << child->GetFilePath().GetPath() << endl; return false; } @@ -246,7 +247,7 @@ bool ResourceAppend::ScanFiles(const unique_ptr &entry, } if (!child->IsFile()) { - cerr << "Error: '" << child->GetFilePath().GetPath() << "' not regular." << endl; + cerr << "Error: '" << child->GetFilePath().GetPath() << "' not file." << endl; return false; } @@ -298,14 +299,14 @@ bool ResourceAppend::ScanSingleFile(const string &filePath, const string &output string fileCuster = path.GetParent().GetFilename(); ResType resType = ResourceUtil::GetResTypeByDir(fileCuster); if (resType == ResType::INVALID_RES_TYPE) { - cerr << "Error: invalid resType '" << filePath << "'" << endl; + cerr << "Error: invalid resType." << NEW_LINE_PATH << filePath << endl; return false; } string limitKey = path.GetParent().GetParent().GetFilename(); vector keyParams; if (!KeyParser::Parse(limitKey, keyParams)) { - cerr << "Error: invalid limit key '" << filePath << "'" << endl; + cerr << "Error: invalid limit key." << NEW_LINE_PATH << filePath << endl; return false; } @@ -337,7 +338,7 @@ bool ResourceAppend::WriteFileInner(ostringstream &outStream, const string &outp #else ofstream out(outputPath, ofstream::out | ofstream::binary); if (!out.is_open()) { - cerr << "Error: open fail '" << outputPath << "'" << endl; + cerr << "Error: open failed '" << outputPath << "', reason: " << strerror(errno) << endl; return false; } out << outStream.str(); @@ -382,7 +383,7 @@ bool ResourceAppend::LoadResourceItem(const string &filePath) #else ifstream in(filePath, ifstream::in | ifstream::binary); if (!in.is_open()) { - cerr << "Error: open fail '" << filePath << "'" << endl; + cerr << "Error: open failed '" << filePath << "', reason: " << strerror(errno) << endl; return false; } @@ -390,7 +391,7 @@ bool ResourceAppend::LoadResourceItem(const string &filePath) int32_t length = in.tellg(); in.seekg(0, in.beg); if (length <= 0) { - cerr << "Error: invalid '" << filePath << "' file size=" << length << endl; + cerr << "Error: invalid file size = " << length << NEW_LINE_PATH << filePath << endl; return false; } char buffer[length]; @@ -430,7 +431,7 @@ bool ResourceAppend::WriteRawFile(const string &filePath, const string &outputPa { string::size_type pos = filePath.find(RAW_FILE_DIR); if (pos == string::npos) { - cerr << "Error: invaild raw file '" << filePath << "'" << endl; + cerr << "Error: invaild raw file." << NEW_LINE_PATH << filePath << endl; return false; } @@ -604,9 +605,9 @@ bool ResourceAppend::CheckModuleResourceItem(const shared_ptr &res }); if (ret != result->second.end()) { - string error = "'" + resourceItem->GetName() + "' conflict, first declared in " + (*ret)->GetFilePath() + \ - ", but declared again in " + resourceItem->GetFilePath(); - cerr << "Error: " << error << endl; + cerr << "Error: '" << resourceItem->GetName() << "' conflict, first declared."; + cerr << NEW_LINE_PATH << (*ret)->GetFilePath() << endl; + cerr << "but declared again." << NEW_LINE_PATH << resourceItem->GetFilePath() << endl; return false; } @@ -621,7 +622,7 @@ bool ResourceAppend::LoadResourceItemWin(const string &filePath) HANDLE hReadFile = CreateFile(filePath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_RANDOM_ACCESS, nullptr); if (hReadFile == INVALID_HANDLE_VALUE) { - cerr << "Error: '" << filePath << "' " << GetLastError() << endl; + cerr << "Error: "<< GetLastError() << NEW_LINE_PATH << filePath << endl; return result; } diff --git a/src/resource_directory.cpp b/src/resource_directory.cpp index ebef655..3c2f2a3 100644 --- a/src/resource_directory.cpp +++ b/src/resource_directory.cpp @@ -57,7 +57,7 @@ bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, c { vector keyParams; if (!KeyParser::Parse(limitKey, keyParams)) { - cerr << "Error: " << resourceTypeDir << ",invalid limit key '" << limitKey << "'" << endl; + cerr << "Error: invalid limit key '" << limitKey << "'." << NEW_LINE_PATH << resourceTypeDir << endl; return false; } @@ -84,7 +84,7 @@ bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, c array.append("'" + item.first + "' "); } array.append("]"); - cerr << "Error: " << dirPath << " ,invalid directory name '"; + cerr << "Error: '" << dirPath << "', invalid directory name '"; cerr << fileCluster << "', must in " << array << endl; return false; } diff --git a/src/resource_module.cpp b/src/resource_module.cpp index 0724693..57cc968 100644 --- a/src/resource_module.cpp +++ b/src/resource_module.cpp @@ -95,13 +95,15 @@ uint32_t ResourceModule::MergeResourceItem(map> &a result.first->second.push_back(resourceItem); continue; } - string error = resourceItem.GetName() + "' conflict, first declared in " + \ - ret->GetFilePath() + ", but declared again in " + resourceItem.GetFilePath(); if (tipError) { - cerr << "Error: " << error << endl; + cerr << "Error: '"<< resourceItem.GetName() <<"' conflict, first declared."; + cerr << NEW_LINE_PATH << ret->GetFilePath() << endl; + cerr << "but declared again." <GetFilePath() << endl; + cout << "but declared again." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; } } return RESTOOL_SUCCESS; diff --git a/src/resource_module_inc.cpp b/src/resource_module_inc.cpp index bd24514..6b4f508 100644 --- a/src/resource_module_inc.cpp +++ b/src/resource_module_inc.cpp @@ -45,7 +45,7 @@ uint32_t ResourceModuleInc::ScanResource(const vector ofstream out(indexFilePath_, ofstream::out | ofstream::binary); if (!out.is_open()) { - cerr << "Error: open fail " << indexFilePath_ << endl; + cerr << "Error: open failed '" << indexFilePath_ << ", reason: " << strerror(errno) << endl; return RESTOOL_ERROR; } diff --git a/src/resource_util.cpp b/src/resource_util.cpp index 4da5f13..3c3fd8a 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -72,8 +72,8 @@ bool ResourceUtil::RmoveAllDir(const string &path) bool ResourceUtil::OpenJsonFile(const string &path, Json::Value &root) { ifstream ifs(path, ios::binary); - if (!ifs) { - cerr << "Error: open json failed '" << path << "'" << endl; + if (!ifs.is_open()) { + cerr << "Error: open json failed '" << path << "', reason: " << strerror(errno) << endl; return false; } @@ -82,7 +82,7 @@ bool ResourceUtil::OpenJsonFile(const string &path, Json::Value &root) readBuilder["failIfExtra"] = true; JSONCPP_STRING errs; if (!parseFromStream(readBuilder, ifs, &root, &errs)) { - cerr << "Error: parseFromStream '" << path; + cerr << "Error: parseFromStream failed." << NEW_LINE_PATH << path; cerr << "\n" << errs << endl; ifs.close(); return false; @@ -99,7 +99,7 @@ bool ResourceUtil::SaveToJsonFile(const string &path, const Json::Value &root) unique_ptr writer(writerBuilder.newStreamWriter()); ofstream out(path, ofstream::out | ofstream::binary); if (!out.is_open()) { - cerr << "Error: open fail " << path << endl; + cerr << "Error: open failed '" << path <<"', reason: " << strerror(errno) << endl; return false; } writer->write(root, &out); @@ -213,7 +213,7 @@ ResType ResourceUtil::GetResTypeFromString(const string &type) bool ResourceUtil::CopyFleInner(const string &src, const string &dst) { if (!FileEntry::CopyFileInner(src, dst)) { - cerr << "Error: copy file fail from '" << src << "' to '" << dst << "'" << endl; + cerr << "Error: copy file fail from '" << src << "' to '" << dst << "'." << endl; return false; } return true; @@ -226,7 +226,7 @@ bool ResourceUtil::CreateDirs(const string &filePath) } if (!FileEntry::CreateDirs(filePath)) { - cerr << "Error: create dir fail '" << filePath << "'" << endl; + cerr << "Error: create dir fail '" << filePath << "'." << endl; return false; } return true; diff --git a/src/xml/solid_xml.cpp b/src/xml/solid_xml.cpp index bd7f9f6..afd72ff 100644 --- a/src/xml/solid_xml.cpp +++ b/src/xml/solid_xml.cpp @@ -14,9 +14,10 @@ */ #include "solid_xml.h" -#include -#include +#include +#include #include "securec.h" +#include "resource_util.h" namespace OHOS { namespace Global { @@ -243,7 +244,7 @@ bool SolidXml::SaveToFile(const std::string &filePath) const { ofstream out(filePath, ofstream::out | ofstream::binary); if (!out.is_open()) { - cerr << "Error: open fail," << filePath << endl; + cerr << "Error: open failed '" << filePath << "', reason: " << strerror(errno) << endl; return false; } @@ -299,7 +300,7 @@ bool SolidXml::LoadFromFile(const string &sxmlPath) { ifstream in(sxmlPath, ifstream::in | ifstream::binary); if (!in.is_open()) { - cerr << "Error: open fail," << sxmlPath << endl; + cerr << "Error: open failed '" << sxmlPath << "', reason: " << strerror(errno) << endl; return false; } diff --git a/src/xml/xml_key_node.cpp b/src/xml/xml_key_node.cpp index 3b59a5f..c9cceed 100644 --- a/src/xml/xml_key_node.cpp +++ b/src/xml/xml_key_node.cpp @@ -14,10 +14,11 @@ */ #include "xml_key_node.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include "resource_util.h" namespace OHOS { namespace Global { @@ -51,7 +52,7 @@ bool XmlKeyNode::SaveToFile(const string &filePath) const { ofstream out(filePath, ofstream::out | ofstream::binary); if (!out.is_open()) { - cerr << "Error: open fail," << filePath << endl; + cerr << "Error: open failed '" << filePath << "', reason: " << strerror(errno) << endl; return false; } @@ -77,7 +78,7 @@ bool XmlKeyNode::LoadFromFile(const std::string &filePath, RefParser parser) { ifstream in(filePath, ifstream::in | ifstream::binary); if (!in.is_open()) { - cerr << "Error: open fail," << filePath << endl; + cerr << "Error: open failed '" << filePath << "', reason: " << strerror(errno) << endl; return false; }