mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 09:14:48 -04:00
@@ -108,7 +108,8 @@ private:
|
||||
std::string idDefinedInputPath_;
|
||||
bool isIconCheck_ = false;
|
||||
TargetConfig targetConfig_;
|
||||
bool isTtargetConfig_;
|
||||
bool isTargetConfig_ = false;
|
||||
std::string targetConfigValue_;
|
||||
std::vector<std::string> sysIdDefinedPaths_;
|
||||
std::string compressionPath_;
|
||||
size_t threadCount_{ 0 };
|
||||
|
||||
@@ -63,6 +63,10 @@ public:
|
||||
{
|
||||
return moduleType_ == ModuleType::HAR;
|
||||
}
|
||||
std::string GetConfigFilePath()
|
||||
{
|
||||
return filePath_;
|
||||
}
|
||||
static void SetUseModule()
|
||||
{
|
||||
useModule_ = true;
|
||||
|
||||
@@ -38,16 +38,16 @@ public:
|
||||
uint32_t Init();
|
||||
private:
|
||||
uint32_t Init(const std::string &filePath, bool isSystem);
|
||||
using ParseFunction = std::function<bool(const cJSON *, ResourceId&)>;
|
||||
using ParseFunction = std::function<bool(const std::string &filePath, const cJSON *, ResourceId&)>;
|
||||
void InitParser();
|
||||
uint32_t IdDefinedToResourceIds(const std::string &filePath, const cJSON *record,
|
||||
bool isSystem, const int64_t strtSysId = 0);
|
||||
bool ParseType(const cJSON *type, ResourceId &resourceId);
|
||||
bool ParseName(const cJSON *name, ResourceId &resourceId);
|
||||
bool ParseOrder(const cJSON *order, ResourceId &resourceId);
|
||||
bool ParseId(const cJSON *id, ResourceId &resourceId);
|
||||
bool ParseType(const std::string &filePath, const cJSON *type, ResourceId &resourceId);
|
||||
bool ParseName(const std::string &filePath, const cJSON *name, ResourceId &resourceId);
|
||||
bool ParseOrder(const std::string &filePath, const cJSON *order, ResourceId &resourceId);
|
||||
bool ParseId(const std::string &filePath, const cJSON *id, ResourceId &resourceId);
|
||||
bool PushResourceId(const std::string &filePath, const ResourceId &resourceId, bool isSystem);
|
||||
int64_t GetStartId() const;
|
||||
int64_t GetStartId(const std::string &filePath) const;
|
||||
std::map<std::string, std::vector<std::pair<ResType, std::string>>> checkDefinedIds_;
|
||||
std::map<std::pair<ResType, std::string>, ResourceId> sysDefinedIds_;
|
||||
std::map<std::pair<ResType, std::string>, ResourceId> appDefinedIds_;
|
||||
|
||||
@@ -34,12 +34,13 @@ private:
|
||||
void InitFileListCommand(HandleBack callback);
|
||||
using HandleFileListValue = std::function<uint32_t(const cJSON *)>;
|
||||
std::map<std::string, HandleFileListValue> fileListHandles_;
|
||||
uint32_t GetString(const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetArray(const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetString(const std::string &nodeName, const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetArray(const std::string &nodeName, const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetModuleNames(const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetBool(const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetNumber(const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetBool(const std::string &nodeName, const cJSON *node, int c, HandleBack callback);
|
||||
uint32_t GetNumber(const std::string &nodeName, const cJSON *node, int c, HandleBack callback);
|
||||
cJSON *root_;
|
||||
std::string filePath_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ constexpr uint32_t RESTOOL_SUCCESS = 0;
|
||||
constexpr uint32_t RESTOOL_ERROR = -1;
|
||||
constexpr uint16_t BUFFER_SIZE = 4096;
|
||||
// 11200xxx unknown error
|
||||
constexpr uint32_t ERR_CODE_UNDEFINED_ERROR = 11200000;
|
||||
|
||||
// 11201xxx dependency error
|
||||
const std::string ERR_TYPE_DEPENDENCY = "Dependency Error";
|
||||
@@ -49,20 +50,10 @@ constexpr uint32_t ERR_CODE_JSON_INVALID_NODE_NAME = 11203007;
|
||||
// 11204xxx file resource error
|
||||
const std::string ERR_TYPE_FILE_RESOURCE = "File Resource Error";
|
||||
constexpr uint32_t ERR_CODE_CREATE_FILE_ERROR = 11204001;
|
||||
constexpr uint32_t ERR_CODE_FILE_NOT_EXIST = 11204002;
|
||||
constexpr uint32_t ERR_CODE_REMOVE_FILE_ERROR = 11204003;
|
||||
constexpr uint32_t ERR_CODE_COPY_FILE_ERROR = 11204004;
|
||||
constexpr uint32_t ERR_CODE_OPEN_FILE_ERROR = 11204005;
|
||||
constexpr uint32_t ERR_CODE_FILE_EMPTY = 11204006;
|
||||
constexpr uint32_t ERR_CODE_FILE_STREAM_ERROR = 11204007;
|
||||
constexpr uint32_t ERR_CODE_FILE_MAP_ERROR = 11204008;
|
||||
|
||||
// 11205xxx syntax error
|
||||
const std::string ERR_TYPE_SYNTAX = "Syntax Error";
|
||||
constexpr uint32_t ERR_CODE_SET_DATA_ERROR = 11205001;
|
||||
constexpr uint32_t ERR_CODE_ITEM_DATA_NULL = 11205002;
|
||||
constexpr uint32_t ERR_CODE_MEMCPY_ERROR = 11205003;
|
||||
constexpr uint32_t ERR_CODE_CREATE_JSON_ERROR = 11205004;
|
||||
constexpr uint32_t ERR_CODE_READ_FILE_ERROR = 11204006;
|
||||
|
||||
// 11210xxx parse command error
|
||||
const std::string ERR_TYPE_COMMAND_PARSE = "Command Parse Error";
|
||||
@@ -100,22 +91,15 @@ constexpr uint32_t ERR_CODE_OUTPUT_EXIST = 11211001;
|
||||
constexpr uint32_t ERR_CODE_CONFIG_JSON_MISSING = 11211002;
|
||||
constexpr uint32_t ERR_CODE_INVALID_MODULE_TYPE = 11211003;
|
||||
constexpr uint32_t ERR_CODE_EXCLUSIVE_START_ID = 11211004;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_NODE_MISSING = 11211005;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_NODE_MISMATCH = 11211006;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_INVALID_TYPE = 11211007;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_INVALID_ID = 11211008;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_ID_OUT_RANGE = 11211009;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_ORDER_MISMATCH = 11211010;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_INVALID_START_ID = 11211011;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_SAME_ID = 11211012;
|
||||
constexpr uint32_t ERR_CODE_ID_DEFINED_SAME_RESOURCE = 11211013;
|
||||
constexpr uint32_t ERR_CODE_MODULE_NAME_NOT_FOUND = 11211014;
|
||||
|
||||
constexpr uint32_t ERR_CODE_RESOURCE_PATH_NOT_DIR = 11211101;
|
||||
constexpr uint32_t ERR_CODE_INVALID_FILE_PATH = 11211102;
|
||||
constexpr uint32_t ERR_CODE_INVALID_RESOURCE_PATH = 11211101;
|
||||
constexpr uint32_t ERR_CODE_INVALID_LIMIT_KEY = 11211103;
|
||||
constexpr uint32_t ERR_CODE_INVALID_RESOURCE_DIR = 11211104;
|
||||
constexpr uint32_t ERR_CODE_RESOURCE_PATH_NOT_FILE = 11211105;
|
||||
constexpr uint32_t ERR_CODE_INVALID_TRANSLATE_PRIORITY = 11211106;
|
||||
constexpr uint32_t ERR_CODE_INVALID_ELEMENT_TYPE = 11211107;
|
||||
constexpr uint32_t ERR_CODE_INVALID_COLOR_VALUE = 11211108;
|
||||
@@ -131,15 +115,7 @@ constexpr uint32_t ERR_CODE_RESOURCE_DUPLICATE = 11211117;
|
||||
constexpr uint32_t ERR_CODE_RESOURCE_ID_EXCEED = 11211118;
|
||||
constexpr uint32_t ERR_CODE_RESOURCE_ID_NOT_DEFINED = 11211119;
|
||||
constexpr uint32_t ERR_CODE_REF_NOT_DEFINED = 11211120;
|
||||
constexpr uint32_t ERR_CODE_ARRAY_DECOMPOSE_ERROR = 11211121;
|
||||
constexpr uint32_t ERR_CODE_ARRAY_COMPOSE_ERROR = 11211122;
|
||||
constexpr uint32_t ERR_CODE_FA_ENTRY_NO_ICON_LABEL = 11211123;
|
||||
constexpr uint32_t ERR_CODE_INVALID_RESOURCE_INDEX = 11211124;
|
||||
constexpr uint32_t ERR_CODE_RESOURCE_INDEX_ID_NOT_FOUND = 11211125;
|
||||
constexpr uint32_t ERR_CODE_RESOURCE_INDEX_ITEM_EMPTY = 11211126;
|
||||
constexpr uint32_t ERR_CODE_RESOURCE_INDEX_INVALID_RESTYPE = 11211127;
|
||||
constexpr uint32_t ERR_CODE_SAVE_INDEX_ERROR = 11211128;
|
||||
constexpr uint32_t ERR_CODE_CREATE_ID_DEFINED_ERROR = 11211129;
|
||||
|
||||
// 11212xxx resource dump error
|
||||
const std::string ERR_TYPE_RESOURCE_DUMP = "Resource Dump Error";
|
||||
@@ -186,7 +162,7 @@ private:
|
||||
if (fmt.empty()) {
|
||||
return fmt;
|
||||
}
|
||||
int paramCount = sizeof...(args);
|
||||
size_t paramCount = sizeof...(args);
|
||||
if (paramCount == 0) {
|
||||
return fmt;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ uint32_t AppendCompiler::CompileSingleFile(const FileInfo &fileInfo)
|
||||
|
||||
string data = fileInfo.filePath;
|
||||
if (!resourceItem.SetData(reinterpret_cast<const int8_t *>(data.c_str()), data.length())) {
|
||||
PrintError(GetError(ERR_CODE_SET_DATA_ERROR).FormatCause(resourceItem.GetName().c_str())
|
||||
.SetPosition(fileInfo.filePath));
|
||||
std::string msg = "item data is null, resource name: " + resourceItem.GetName();
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(msg.c_str()).SetPosition(fileInfo.filePath));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ uint32_t BinaryFilePacker::CopyBinaryFile(const string &filePath, const string &
|
||||
}
|
||||
|
||||
if (!FileEntry::IsDirectory(filePath)) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_DIR).FormatCause(filePath.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH).FormatCause(filePath.c_str(), "not a directory"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace Restool {
|
||||
using namespace std;
|
||||
uint32_t DumpParserBase::ParseOption(int argc, char *argv[], int currentIndex)
|
||||
{
|
||||
if (currentIndex >= argc) {
|
||||
if (currentIndex >= argc || currentIndex < 0) {
|
||||
PrintError(ERR_CODE_DUMP_MISSING_INPUT);
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
inputPath_ = ResourceUtil::RealPath(argv[currentIndex]);
|
||||
if (inputPath_.empty()) {
|
||||
PrintError(ERR_CODE_DUMP_INVALID_INPUT);
|
||||
PrintError(GetError(ERR_CODE_DUMP_INVALID_INPUT).FormatCause(argv[currentIndex]));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
return RESTOOL_SUCCESS;
|
||||
|
||||
+26
-10
@@ -251,7 +251,10 @@ uint32_t PackageParser::PrintVersion()
|
||||
uint32_t PackageParser::AddMoudleNames(const string& argValue)
|
||||
{
|
||||
if (!moduleNames_.empty()) {
|
||||
PrintError(GetError(ERR_CODE_DOUBLE_MODULES).FormatCause(argValue.c_str()));
|
||||
std::string existModuleNames;
|
||||
for (const auto &module : moduleNames_) { existModuleNames.append(module).append(","); }
|
||||
existModuleNames.pop_back();
|
||||
PrintError(GetError(ERR_CODE_DOUBLE_MODULES).FormatCause(existModuleNames.c_str(), argValue.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -279,8 +282,19 @@ uint32_t PackageParser::AddConfig(const string& argValue)
|
||||
|
||||
uint32_t PackageParser::AddStartId(const string& argValue)
|
||||
{
|
||||
startId_ = strtoll(argValue.c_str(), nullptr, 16); // 16 is hexadecimal number
|
||||
if ((startId_ >= 0x01000000 && startId_ < 0x06ffffff) || (startId_ >= 0x08000000 && startId_ < 0xffffffff)) {
|
||||
char *end;
|
||||
errno = 0;
|
||||
long long id = static_cast<long long>(strtoll(argValue.c_str(), &end, 16)); // 16 is hexadecimal number
|
||||
if (end == argValue.c_str() || errno == ERANGE || *end != '\0' || id == LLONG_MAX || id == LLONG_MIN) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_START_ID).FormatCause(argValue.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (id <= 0) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_START_ID).FormatCause(argValue.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if ((id >= 0x01000000 && id < 0x06ffffff) || (id >= 0x08000000 && id < 0xffffffff)) {
|
||||
startId_ = static_cast<uint32_t>(id);
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
PrintError(GetError(ERR_CODE_INVALID_START_ID).FormatCause(argValue.c_str()));
|
||||
@@ -309,7 +323,7 @@ uint32_t PackageParser::CheckParam() const
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
if (isTtargetConfig_ && !append_.empty()) {
|
||||
if (isTargetConfig_ && !append_.empty()) {
|
||||
PrintError(GetError(ERR_CODE_EXCLUSIVE_OPTION).FormatCause("-x", "--target-config"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
@@ -425,15 +439,16 @@ bool PackageParser::GetIconCheck() const
|
||||
|
||||
uint32_t PackageParser::ParseTargetConfig(const string& argValue)
|
||||
{
|
||||
if (isTtargetConfig_) {
|
||||
PrintError(ERR_CODE_DOUBLE_TARGET_CONFIG);
|
||||
if (isTargetConfig_) {
|
||||
PrintError(GetError(ERR_CODE_DOUBLE_TARGET_CONFIG).FormatCause(targetConfigValue_.c_str(), argValue.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (!SelectCompileParse::ParseTargetConfig(argValue, targetConfig_)) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_TARGET_CONFIG).FormatCause(argValue.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
isTtargetConfig_ = true;
|
||||
isTargetConfig_ = true;
|
||||
targetConfigValue_ = argValue;
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -453,7 +468,7 @@ uint32_t PackageParser::ParseThread(const std::string &argValue)
|
||||
PrintError(GetError(ERR_CODE_INVALID_THREAD_COUNT).FormatCause(argValue.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
threadCount_ = count;
|
||||
threadCount_ = static_cast<size_t>(count);
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -469,7 +484,7 @@ const TargetConfig &PackageParser::GetTargetConfigValues() const
|
||||
|
||||
bool PackageParser::IsTargetConfig() const
|
||||
{
|
||||
return isTtargetConfig_;
|
||||
return isTargetConfig_;
|
||||
}
|
||||
|
||||
bool PackageParser::IsAscii(const string& argValue) const
|
||||
@@ -606,8 +621,9 @@ uint32_t PackageParser::ParseCommand(int argc, char *argv[])
|
||||
}
|
||||
string errmsg;
|
||||
for (int i = optind; i < argc; i++) {
|
||||
errmsg.append(argv[i]).append(" ");
|
||||
errmsg.append(argv[i]).append(",");
|
||||
}
|
||||
errmsg.pop_back();
|
||||
PrintError(GetError(ERR_CODE_INVALID_ARGUMENT).FormatCause(errmsg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode)
|
||||
return true;
|
||||
}
|
||||
if (!cJSON_IsObject(compressionNode)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("compression", "object"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("compression", "object").SetPosition(filePath_));
|
||||
return false;
|
||||
}
|
||||
cJSON *mediaNode = cJSON_GetObjectItem(compressionNode, "media");
|
||||
@@ -140,7 +140,7 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode)
|
||||
return true;
|
||||
}
|
||||
if (!cJSON_IsObject(mediaNode)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("media", "object"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("media", "object").SetPosition(filePath_));
|
||||
return false;
|
||||
}
|
||||
cJSON *enableNode = cJSON_GetObjectItem(mediaNode, "enable");
|
||||
@@ -150,7 +150,7 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode)
|
||||
return true;
|
||||
}
|
||||
if (!cJSON_IsBool(enableNode)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("enable", "bool"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("enable", "bool").SetPosition(filePath_));
|
||||
return false;
|
||||
}
|
||||
mediaSwitch_ = cJSON_IsTrue(enableNode);
|
||||
@@ -590,7 +590,7 @@ bool CompressionParser::CopyAndTranscode(const string &src, string &dst, const b
|
||||
|
||||
auto index = dst.find_last_of(SEPARATOR_FILE);
|
||||
if (index == string::npos) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_FILE_PATH).FormatCause(dst.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH).FormatCause(dst.c_str(), "missing separator"));
|
||||
return false;
|
||||
}
|
||||
uint32_t startIndex = outPath_.size() + RESOURCES_DIR.size() + 1;
|
||||
@@ -621,7 +621,7 @@ bool CompressionParser::CheckAndScaleIcon(const std::string &src, const std::str
|
||||
}
|
||||
auto index = originDst.find_last_of(SEPARATOR_FILE);
|
||||
if (index == string::npos) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_FILE_PATH).FormatCause(originDst.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH).FormatCause(originDst.c_str(), "missing separator"));
|
||||
return false;
|
||||
}
|
||||
uint32_t startIndex = outPath_.size() + RESOURCES_DIR.size() + 1;
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ bool FileEntry::Init()
|
||||
{
|
||||
string filePath = filePath_.GetPath();
|
||||
if (!Exist(filePath)) {
|
||||
PrintError(GetError(ERR_CODE_FILE_NOT_EXIST).FormatCause(filePath.c_str()));
|
||||
cout << "Warning: file not exist: " << filePath << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,8 @@ bool FileManager::ScaleIcon(const string &output, ResourceItem &item)
|
||||
std::string newData = moduleName_ + SEPARATOR + RESOURCES_DIR + SEPARATOR + item.GetLimitKey() + SEPARATOR + media
|
||||
+ SEPARATOR + newFileName;
|
||||
if (!item.SetData(reinterpret_cast<const int8_t *>(newData.c_str()), newData.length())) {
|
||||
PrintError(GetError(ERR_CODE_SET_DATA_ERROR).FormatCause(item.GetName().c_str())
|
||||
.SetPosition(item.GetFilePath()));
|
||||
std::string msg = "item data is null, resource name: " + item.GetName();
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(msg.c_str()).SetPosition(item.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -76,15 +76,15 @@ bool GenericCompiler::PostMediaFile(const FileInfo &fileInfo, const std::string
|
||||
|
||||
auto index = output.find_last_of(SEPARATOR_FILE);
|
||||
if (index == string::npos) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_FILE_PATH).FormatCause(output.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH).FormatCause(output.c_str(), "missing separator"));
|
||||
return false;
|
||||
}
|
||||
string data = output.substr(index + 1);
|
||||
data = moduleName_ + SEPARATOR + RESOURCES_DIR + SEPARATOR + \
|
||||
fileInfo.limitKey + SEPARATOR + fileInfo.fileCluster + SEPARATOR + data;
|
||||
if (!resourceItem.SetData(reinterpret_cast<const int8_t *>(data.c_str()), data.length())) {
|
||||
PrintError(GetError(ERR_CODE_SET_DATA_ERROR).FormatCause(resourceItem.GetName().c_str())
|
||||
.SetPosition(fileInfo.filePath));
|
||||
std::string msg = "item data is null, resource name: " + resourceItem.GetName();
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(msg.c_str()).SetPosition(fileInfo.filePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ uint32_t IResourceCompiler::Compile(const vector<DirectoryInfo> &directoryInfos)
|
||||
}
|
||||
|
||||
if (!it->IsFile()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_FILE).FormatCause(it->GetFilePath().GetPath().c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH)
|
||||
.FormatCause(it->GetFilePath().GetPath().c_str(), "not a file"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -121,8 +122,8 @@ uint32_t IResourceCompiler::PostCommit()
|
||||
int64_t id = idWorker.GenerateId(nameInfo.first.first, nameInfo.first.second);
|
||||
if (id < 0) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_ID_NOT_DEFINED)
|
||||
.FormatCause(ResourceUtil::ResTypeToString(nameInfo.first.first).c_str(),
|
||||
nameInfo.first.second.c_str()));
|
||||
.FormatCause(nameInfo.first.second.c_str(),
|
||||
ResourceUtil::ResTypeToString(nameInfo.first.first).c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
resourceInfos_.emplace(id, nameInfo.second);
|
||||
|
||||
+37
-32
@@ -50,7 +50,7 @@ uint32_t IdDefinedParser::Init()
|
||||
idDefinedPath = ResourceUtil::GetBaseElementPath(inputPath).Append(ID_DEFINED_FILE).GetPath();
|
||||
}
|
||||
if (ResourceUtil::FileExist(idDefinedPath) && startId > 0) {
|
||||
PrintError(ERR_CODE_EXCLUSIVE_START_ID);
|
||||
PrintError(GetError(ERR_CODE_EXCLUSIVE_START_ID).FormatCause(startId).SetPosition(idDefinedPath));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (Init(idDefinedPath, isSys) != RESTOOL_SUCCESS) {
|
||||
@@ -110,9 +110,8 @@ uint32_t IdDefinedParser::Init(const string &filePath, bool isSystem)
|
||||
}
|
||||
int64_t startSysId = 0;
|
||||
if (isSystem) {
|
||||
startSysId = GetStartId();
|
||||
startSysId = GetStartId(filePath);
|
||||
if (startSysId < 0) {
|
||||
PrintError(ERR_CODE_ID_DEFINED_INVALID_START_ID);
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -126,10 +125,10 @@ uint32_t IdDefinedParser::Init(const string &filePath, bool isSystem)
|
||||
void IdDefinedParser::InitParser()
|
||||
{
|
||||
using namespace placeholders;
|
||||
handles_.emplace("type", bind(&IdDefinedParser::ParseType, this, _1, _2));
|
||||
handles_.emplace("name", bind(&IdDefinedParser::ParseName, this, _1, _2));
|
||||
handles_.emplace("id", bind(&IdDefinedParser::ParseId, this, _1, _2));
|
||||
handles_.emplace("order", bind(&IdDefinedParser::ParseOrder, this, _1, _2));
|
||||
handles_.emplace("type", bind(&IdDefinedParser::ParseType, this, _1, _2, _3));
|
||||
handles_.emplace("name", bind(&IdDefinedParser::ParseName, this, _1, _2, _3));
|
||||
handles_.emplace("id", bind(&IdDefinedParser::ParseId, this, _1, _2, _3));
|
||||
handles_.emplace("order", bind(&IdDefinedParser::ParseOrder, this, _1, _2, _3));
|
||||
}
|
||||
|
||||
uint32_t IdDefinedParser::IdDefinedToResourceIds(const std::string &filePath, const cJSON *record,
|
||||
@@ -150,7 +149,7 @@ uint32_t IdDefinedParser::IdDefinedToResourceIds(const std::string &filePath, co
|
||||
if ((handle.first == "id" && isSystem) || (handle.first == "order" && !isSystem)) {
|
||||
continue;
|
||||
}
|
||||
if (!handle.second(cJSON_GetObjectItem(item, handle.first.c_str()), resourceId)) {
|
||||
if (!handle.second(filePath, cJSON_GetObjectItem(item, handle.first.c_str()), resourceId)) {
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -167,7 +166,7 @@ bool IdDefinedParser::PushResourceId(const std::string &filePath, const Resource
|
||||
auto ret = idDefineds_.emplace(resourceId.id, resourceId);
|
||||
if (!ret.second) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_SAME_ID).FormatCause(ret.first->second.name.c_str(),
|
||||
resourceId.name.c_str()));
|
||||
resourceId.name.c_str()).SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
auto checkRet = checkDefinedIds_.find(filePath);
|
||||
@@ -177,8 +176,8 @@ bool IdDefinedParser::PushResourceId(const std::string &filePath, const Resource
|
||||
return (resType == iterItem.first) && (resourceId.name == iterItem.second);
|
||||
});
|
||||
if (found) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_SAME_RESOURCE).FormatCause(resourceId.name.c_str(),
|
||||
filePath.c_str()));
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_DUPLICATE).FormatCause(resourceId.name.c_str(),
|
||||
filePath.c_str(), filePath.c_str()));
|
||||
return false;
|
||||
}
|
||||
checkRet->second.push_back(make_pair(resType, resourceId.name));
|
||||
@@ -195,56 +194,60 @@ bool IdDefinedParser::PushResourceId(const std::string &filePath, const Resource
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IdDefinedParser::ParseId(const cJSON *origId, ResourceId &resourceId)
|
||||
bool IdDefinedParser::ParseId(const std::string &filePath, const cJSON *origId, ResourceId &resourceId)
|
||||
{
|
||||
if (!origId) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISSING).FormatCause(resourceId.seq, "id"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause("id").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
if (!cJSON_IsString(origId)) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISMATCH).FormatCause(resourceId.seq, "id", "string"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("id", "string").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
string idStr = origId->valuestring;
|
||||
if (!ResourceUtil::CheckHexStr(idStr)) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_INVALID_ID).FormatCause(resourceId.seq));
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_INVALID_ID).FormatCause(idStr.c_str()).SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
int64_t id = strtoll(idStr.c_str(), nullptr, 16);
|
||||
if (id < 0x01000000 || (id > 0x06FFFFFF && id < 0x08000000) || id > 0xFFFFFFFF) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_ID_OUT_RANGE).FormatCause(resourceId.seq));
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_INVALID_ID).FormatCause(idStr.c_str()).SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
resourceId.id = id;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IdDefinedParser::ParseType(const cJSON *type, ResourceId &resourceId)
|
||||
bool IdDefinedParser::ParseType(const std::string &filePath, const cJSON *type, ResourceId &resourceId)
|
||||
{
|
||||
if (!type) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISSING).FormatCause(resourceId.seq, "type"));
|
||||
std::string msg = "type";
|
||||
msg.append(cJSON_GetErrorPtr());
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause("type").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
if (!cJSON_IsString(type)) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISMATCH).FormatCause(resourceId.seq, "type", "string"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("type", "string").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
if (ResourceUtil::GetResTypeFromString(type->valuestring) == ResType::INVALID_RES_TYPE) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_INVALID_TYPE).FormatCause(resourceId.seq, type->valuestring));
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_INVALID_TYPE)
|
||||
.FormatCause(type->valuestring, ResourceUtil::GetAllRestypeString().c_str())
|
||||
.SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
resourceId.type = type->valuestring;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IdDefinedParser::ParseName(const cJSON *name, ResourceId &resourceId)
|
||||
bool IdDefinedParser::ParseName(const std::string &filePath, const cJSON *name, ResourceId &resourceId)
|
||||
{
|
||||
if (!name) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISSING).FormatCause(resourceId.seq, "name"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause("name").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
if (!cJSON_IsString(name)) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISMATCH).FormatCause(resourceId.seq, "name", "string"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("name", "string").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
resourceId.name = name->valuestring;
|
||||
@@ -252,47 +255,49 @@ bool IdDefinedParser::ParseName(const cJSON *name, ResourceId &resourceId)
|
||||
(static_cast<uint64_t>(resourceId.id) & static_cast<uint64_t>(START_SYS_ID)) == START_SYS_ID &&
|
||||
!ResourceUtil::IsValidName(resourceId.name)) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_NAME).FormatCause(resourceId.name.c_str())
|
||||
.SetPosition("id_defined.json"));
|
||||
.SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IdDefinedParser::ParseOrder(const cJSON *order, ResourceId &resourceId)
|
||||
bool IdDefinedParser::ParseOrder(const std::string &filePath, const cJSON *order, ResourceId &resourceId)
|
||||
{
|
||||
if (!order) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISSING).FormatCause(resourceId.seq, "order"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause("order").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
if (!ResourceUtil::IsIntValue(order)) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_NODE_MISMATCH).FormatCause(resourceId.seq, "order", "int"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("order", "integer").SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
int64_t orderId = order->valueint;
|
||||
if (orderId != resourceId.seq) {
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_ORDER_MISMATCH).FormatCause(resourceId.seq, orderId, resourceId.seq));
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_ORDER_MISMATCH).FormatCause(orderId, resourceId.seq, resourceId.seq)
|
||||
.SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
resourceId.id = resourceId.id + orderId;
|
||||
return true;
|
||||
}
|
||||
|
||||
int64_t IdDefinedParser::GetStartId() const
|
||||
int64_t IdDefinedParser::GetStartId(const std::string &filePath) const
|
||||
{
|
||||
cJSON *startIdNode = cJSON_GetObjectItem(root_, "startId");
|
||||
if (!startIdNode) {
|
||||
cout << "Warning: id_defined.json 'startId' empty." << endl;
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause("startId").SetPosition(filePath));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(startIdNode)) {
|
||||
cout << "Warning: id_defined.json 'startId' not string." << endl;
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause("startId", "string").SetPosition(filePath));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t id = strtoll(startIdNode->valuestring, nullptr, 16);
|
||||
if (id == 0) {
|
||||
cout << "Warning: id_defined.json 'startId' is not a valid hexadecimal string." << endl;
|
||||
PrintError(GetError(ERR_CODE_ID_DEFINED_INVALID_ID).FormatCause(startIdNode->valuestring)
|
||||
.SetPosition(filePath));
|
||||
return -1;
|
||||
}
|
||||
return id;
|
||||
|
||||
+24
-14
@@ -68,7 +68,9 @@ uint32_t JsonCompiler::CompileSingleFile(const FileInfo &fileInfo)
|
||||
string tag = item->string;
|
||||
auto ret = g_contentClusterMap.find(tag);
|
||||
if (ret == g_contentClusterMap.end()) {
|
||||
PrintError(GetError(ERR_CODE_JSON_INVALID_NODE_NAME).FormatCause(tag.c_str()).SetPosition(fileInfo.filePath));
|
||||
PrintError(GetError(ERR_CODE_JSON_INVALID_NODE_NAME)
|
||||
.FormatCause(tag.c_str(), ResourceUtil::GetAllRestypeString().c_str())
|
||||
.SetPosition(fileInfo.filePath));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
isBaseString_ = (fileInfo.limitKey == "base" &&
|
||||
@@ -150,8 +152,15 @@ bool JsonCompiler::ParseJsonObjectLevel(cJSON *objectNode, const FileInfo &fileI
|
||||
resourceItem.SetLimitKey(fileInfo.limitKey);
|
||||
auto ret = handles_.find(fileInfo.fileType);
|
||||
if (ret == handles_.end()) {
|
||||
std::string elementTypes = "[";
|
||||
for (const auto &handle : handles_) {
|
||||
elementTypes.append("\"").append(ResourceUtil::ResTypeToString(handle.first)).append("\",");
|
||||
}
|
||||
elementTypes.pop_back();
|
||||
elementTypes.append("]");
|
||||
PrintError(GetError(ERR_CODE_INVALID_ELEMENT_TYPE)
|
||||
.FormatCause(ResourceUtil::ResTypeToString(fileInfo.fileType).c_str()));
|
||||
.FormatCause(ResourceUtil::ResTypeToString(fileInfo.fileType).c_str(), elementTypes.c_str())
|
||||
.SetPosition(fileInfo.filePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -296,7 +305,7 @@ bool JsonCompiler::HandlePlural(const cJSON *objectNode, ResourceItem &resourceI
|
||||
string quantityValue = quantityNode->valuestring;
|
||||
if (find(attrs.begin(), attrs.end(), quantityValue) != attrs.end()) {
|
||||
PrintError(GetError(ERR_CODE_DUPLICATE_QUANTITY)
|
||||
.FormatCause(resourceItem.GetName().c_str(), quantityValue.c_str())
|
||||
.FormatCause(quantityValue.c_str(), resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
@@ -332,8 +341,8 @@ bool JsonCompiler::HandleSymbol(const cJSON *objectNode, ResourceItem &resourceI
|
||||
bool JsonCompiler::PushString(const string &value, ResourceItem &resourceItem) const
|
||||
{
|
||||
if (!resourceItem.SetData(reinterpret_cast<const int8_t *>(value.c_str()), value.length())) {
|
||||
PrintError(GetError(ERR_CODE_SET_DATA_ERROR).FormatCause(resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
std::string msg = "item data is null, resource name: " + resourceItem.GetName();
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(msg.c_str()).SetPosition(resourceItem.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -358,7 +367,7 @@ bool JsonCompiler::CheckJsonStringValue(const cJSON *valueNode, const ResourceIt
|
||||
string value = valueNode->valuestring;
|
||||
ResType type = resourceItem.GetResType();
|
||||
if (type == ResType::COLOR && !CheckColorValue(value.c_str())) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_COLOR_VALUE).FormatCause(value.c_str())
|
||||
PrintError(GetError(ERR_CODE_INVALID_COLOR_VALUE).FormatCause(value.c_str(), resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
@@ -409,7 +418,7 @@ bool JsonCompiler::CheckJsonSymbolValue(const cJSON *valueNode, const ResourceIt
|
||||
}
|
||||
int unicode = strtol(unicodeStr.c_str(), nullptr, 16);
|
||||
if (!ResourceUtil::isUnicodeInPlane15or16(unicode)) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_SYMBOL).FormatCause(resourceItem.GetName().c_str())
|
||||
PrintError(GetError(ERR_CODE_INVALID_SYMBOL).FormatCause(unicode, resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
@@ -476,9 +485,8 @@ bool JsonCompiler::ParseParent(const cJSON *objectNode, const ResourceItem &reso
|
||||
}
|
||||
string parentValue = parentNode->valuestring;
|
||||
if (parentValue.empty()) {
|
||||
PrintError(GetError(ERR_CODE_PARENT_EMPTY)
|
||||
.FormatCause(type.c_str(), resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
PrintError(GetError(ERR_CODE_PARENT_EMPTY).FormatCause(resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
if (regex_match(parentValue, regex("^ohos:" + type + ":.+"))) {
|
||||
@@ -555,12 +563,14 @@ bool JsonCompiler::CheckPluralValue(const cJSON *arrayItem, const ResourceItem &
|
||||
}
|
||||
string quantityValue = quantityNode->valuestring;
|
||||
if (find(QUANTITY_ATTRS.begin(), QUANTITY_ATTRS.end(), quantityValue) == QUANTITY_ATTRS.end()) {
|
||||
string buffer(" ");
|
||||
string buffer("[");
|
||||
for_each(QUANTITY_ATTRS.begin(), QUANTITY_ATTRS.end(), [&buffer](auto iter) {
|
||||
buffer.append(iter).append(" ");
|
||||
});
|
||||
buffer.append("\"").append(iter).append("\",");
|
||||
});
|
||||
buffer.pop_back();
|
||||
buffer.append("]");
|
||||
PrintError(GetError(ERR_CODE_INVALID_QUANTITY)
|
||||
.FormatCause(resourceItem.GetName().c_str(), quantityValue.c_str(), buffer.c_str())
|
||||
.FormatCause(quantityValue.c_str(), resourceItem.GetName().c_str(), buffer.c_str())
|
||||
.SetPosition(filePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,8 @@ uint32_t ReferenceParser::ParseRefInResourceItem(ResourceItem &resourceItem) con
|
||||
bool update = false;
|
||||
if (IsStringOfResourceItem(resType)) {
|
||||
if (resourceItem.GetData() == nullptr) {
|
||||
PrintError(GetError(ERR_CODE_ITEM_DATA_NULL).FormatCause(resourceItem.GetName().c_str()));
|
||||
std::string msg = "item data is null, resource name: " + resourceItem.GetName();
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(msg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
data = string(reinterpret_cast<const char *>(resourceItem.GetData()), resourceItem.GetDataLength());
|
||||
@@ -111,8 +112,8 @@ uint32_t ReferenceParser::ParseRefInResourceItem(ResourceItem &resourceItem) con
|
||||
}
|
||||
}
|
||||
if (update && !resourceItem.SetData(reinterpret_cast<const int8_t *>(data.c_str()), data.length())) {
|
||||
PrintError(GetError(ERR_CODE_SET_DATA_ERROR).FormatCause(resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
std::string msg = "item data is null, resource name: " + resourceItem.GetName();
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(msg.c_str()).SetPosition(resourceItem.GetFilePath()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
return RESTOOL_SUCCESS;
|
||||
@@ -188,13 +189,14 @@ bool ReferenceParser::ParseRefJson(const string &from, const string &to)
|
||||
bool ReferenceParser::ParseRefResourceItemData(const ResourceItem &resourceItem, string &data, bool &update) const
|
||||
{
|
||||
if (resourceItem.GetData() == nullptr) {
|
||||
PrintError(GetError(ERR_CODE_ITEM_DATA_NULL).FormatCause(resourceItem.GetName().c_str()));
|
||||
std::string msg = "item data is null, resource name: " + resourceItem.GetName();
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(msg.c_str()));
|
||||
return false;
|
||||
}
|
||||
data = string(reinterpret_cast<const char *>(resourceItem.GetData()), resourceItem.GetDataLength());
|
||||
vector<string> contents = ResourceUtil::DecomposeStrings(data);
|
||||
if (contents.empty()) {
|
||||
PrintError(GetError(ERR_CODE_ARRAY_DECOMPOSE_ERROR).FormatCause(resourceItem.GetName().c_str(), data.c_str())
|
||||
PrintError(GetError(ERR_CODE_ARRAY_TOO_LARGE).FormatCause(resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
@@ -213,7 +215,7 @@ bool ReferenceParser::ParseRefResourceItemData(const ResourceItem &resourceItem,
|
||||
|
||||
data = ResourceUtil::ComposeStrings(contents);
|
||||
if (data.empty()) {
|
||||
PrintError(GetError(ERR_CODE_ARRAY_COMPOSE_ERROR).FormatCause(resourceItem.GetName().c_str(), contents.size())
|
||||
PrintError(GetError(ERR_CODE_ARRAY_TOO_LARGE).FormatCause(resourceItem.GetName().c_str())
|
||||
.SetPosition(resourceItem.GetFilePath()));
|
||||
return false;
|
||||
}
|
||||
|
||||
+50
-33
@@ -30,6 +30,7 @@ ResConfigParser::~ResConfigParser()
|
||||
}
|
||||
uint32_t ResConfigParser::Init(const string &filePath, HandleBack callback)
|
||||
{
|
||||
filePath_ = filePath;
|
||||
if (!ResourceUtil::OpenJsonFile(filePath, &root_)) {
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
@@ -62,44 +63,47 @@ uint32_t ResConfigParser::Init(const string &filePath, HandleBack callback)
|
||||
void ResConfigParser::InitFileListCommand(HandleBack callback)
|
||||
{
|
||||
using namespace placeholders;
|
||||
fileListHandles_.emplace("configPath", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("configPath", bind(&ResConfigParser::GetString, this, "configPath", _1,
|
||||
Option::JSON, callback));
|
||||
fileListHandles_.emplace("packageName", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("packageName", bind(&ResConfigParser::GetString, this, "packageName", _1,
|
||||
Option::PACKAGENAME, callback));
|
||||
fileListHandles_.emplace("output", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("output", bind(&ResConfigParser::GetString, this, "output", _1,
|
||||
Option::OUTPUTPATH, callback));
|
||||
fileListHandles_.emplace("startId", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("startId", bind(&ResConfigParser::GetString, this, "startId", _1,
|
||||
Option::STARTID, callback));
|
||||
fileListHandles_.emplace("entryCompiledResource", bind(&ResConfigParser::GetString, this, _1,
|
||||
Option::DEPENDENTRY, callback));
|
||||
fileListHandles_.emplace("ids", bind(&ResConfigParser::GetString, this, _1,
|
||||
Option::IDS, callback));
|
||||
fileListHandles_.emplace("definedIds", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("entryCompiledResource", bind(&ResConfigParser::GetString, this, "entryCompiledResource",
|
||||
_1, Option::DEPENDENTRY, callback));
|
||||
fileListHandles_.emplace("ids", bind(&ResConfigParser::GetString, this, "ids", _1, Option::IDS, callback));
|
||||
fileListHandles_.emplace("definedIds", bind(&ResConfigParser::GetString, this, "definedIds", _1,
|
||||
Option::DEFINED_IDS, callback));
|
||||
fileListHandles_.emplace("applicationResource", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("applicationResource", bind(&ResConfigParser::GetString, this, "applicationResource", _1,
|
||||
Option::INPUTPATH, callback));
|
||||
fileListHandles_.emplace("ResourceTable", bind(&ResConfigParser::GetArray, this, _1,
|
||||
fileListHandles_.emplace("ResourceTable", bind(&ResConfigParser::GetArray, this, "ResourceTable", _1,
|
||||
Option::RESHEADER, callback));
|
||||
fileListHandles_.emplace("moduleResources", bind(&ResConfigParser::GetArray, this, _1,
|
||||
fileListHandles_.emplace("moduleResources", bind(&ResConfigParser::GetArray, this, "moduleResources", _1,
|
||||
Option::INPUTPATH, callback));
|
||||
fileListHandles_.emplace("dependencies", bind(&ResConfigParser::GetArray, this, _1,
|
||||
fileListHandles_.emplace("dependencies", bind(&ResConfigParser::GetArray, this, "dependencies", _1,
|
||||
Option::INPUTPATH, callback));
|
||||
fileListHandles_.emplace("moduleNames", bind(&ResConfigParser::GetModuleNames, this, _1,
|
||||
Option::MODULES, callback));
|
||||
fileListHandles_.emplace("iconCheck", bind(&ResConfigParser::GetBool, this, _1,
|
||||
fileListHandles_.emplace("iconCheck", bind(&ResConfigParser::GetBool, this, "iconCheck", _1,
|
||||
Option::ICON_CHECK, callback));
|
||||
fileListHandles_.emplace("definedSysIds", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("definedSysIds", bind(&ResConfigParser::GetString, this, "definedSysIds", _1,
|
||||
Option::DEFINED_SYSIDS, callback));
|
||||
fileListHandles_.emplace("compression", bind(&ResConfigParser::GetString, this, _1,
|
||||
fileListHandles_.emplace("compression", bind(&ResConfigParser::GetString, this, "compression", _1,
|
||||
Option::COMPRESSED_CONFIG, callback));
|
||||
fileListHandles_.emplace("thread", bind(&ResConfigParser::GetNumber, this, _1,
|
||||
fileListHandles_.emplace("thread", bind(&ResConfigParser::GetNumber, this, "thread", _1,
|
||||
Option::THREAD, callback));
|
||||
}
|
||||
|
||||
uint32_t ResConfigParser::GetString(const cJSON *node, int c, HandleBack callback)
|
||||
uint32_t ResConfigParser::GetString(const std::string &nodeName, const cJSON *node, int c, HandleBack callback)
|
||||
{
|
||||
if (!node || !cJSON_IsString(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "string"));
|
||||
if (!node) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause(nodeName.c_str()).SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (!cJSON_IsString(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "string").SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -109,16 +113,21 @@ uint32_t ResConfigParser::GetString(const cJSON *node, int c, HandleBack callbac
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t ResConfigParser::GetArray(const cJSON *node, int c, HandleBack callback)
|
||||
uint32_t ResConfigParser::GetArray(const std::string &nodeName, const cJSON *node, int c, HandleBack callback)
|
||||
{
|
||||
if (!node || !cJSON_IsArray(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "array"));
|
||||
if (!node) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause(nodeName.c_str()).SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (!cJSON_IsArray(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "array").SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
for (cJSON *item = node->child; item; item = item->next) {
|
||||
if (!cJSON_IsString(item)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(item->string, "string"));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(item->string, "string")
|
||||
.SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (callback(c, item->valuestring) != RESTOOL_SUCCESS) {
|
||||
@@ -131,14 +140,14 @@ uint32_t ResConfigParser::GetArray(const cJSON *node, int c, HandleBack callback
|
||||
uint32_t ResConfigParser::GetModuleNames(const cJSON *node, int c, HandleBack callback)
|
||||
{
|
||||
if (!node) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause(node->string));
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause("moduleNames").SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (cJSON_IsString(node)) {
|
||||
return GetString(node, c, callback);
|
||||
return GetString("moduleNames", node, c, callback);
|
||||
}
|
||||
string moduleNames;
|
||||
if (GetArray(node, c, [&moduleNames](int c, const string &argValue) {
|
||||
if (GetArray("moduleNames", node, c, [&moduleNames](int c, const string &argValue) {
|
||||
if (!moduleNames.empty()) {
|
||||
moduleNames.append(",");
|
||||
}
|
||||
@@ -154,10 +163,14 @@ uint32_t ResConfigParser::GetModuleNames(const cJSON *node, int c, HandleBack ca
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t ResConfigParser::GetBool(const cJSON *node, int c, HandleBack callback)
|
||||
uint32_t ResConfigParser::GetBool(const std::string &nodeName, const cJSON *node, int c, HandleBack callback)
|
||||
{
|
||||
if (!node || !cJSON_IsBool(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "bool"));
|
||||
if (!node) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause(nodeName.c_str()).SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (!cJSON_IsBool(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "bool").SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -167,10 +180,14 @@ uint32_t ResConfigParser::GetBool(const cJSON *node, int c, HandleBack callback)
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t ResConfigParser::GetNumber(const cJSON *node, int c, HandleBack callback)
|
||||
uint32_t ResConfigParser::GetNumber(const std::string &nodeName, const cJSON *node, int c, HandleBack callback)
|
||||
{
|
||||
if (!node || !cJSON_IsNumber(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "number"));
|
||||
if (!node) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISSING).FormatCause(nodeName.c_str()).SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (!cJSON_IsNumber(node)) {
|
||||
PrintError(GetError(ERR_CODE_JSON_NODE_MISMATCH).FormatCause(node->string, "number").SetPosition(filePath_));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
+14
-10
@@ -86,7 +86,8 @@ bool ResourceAppend::Combine(const string &folderPath)
|
||||
itemsForModule_.clear();
|
||||
for (const auto &child : entry.GetChilds()) {
|
||||
if (!child->IsFile()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_FILE).FormatCause(child->GetFilePath().GetPath().c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH)
|
||||
.FormatCause(child->GetFilePath().GetPath().c_str(), "not a file"));
|
||||
return false;
|
||||
}
|
||||
if (child->GetFilePath().GetFilename() == ID_DEFINED_FILE) {
|
||||
@@ -176,7 +177,8 @@ bool ResourceAppend::ScanSubLimitkeyResources(const FileEntry entry, const strin
|
||||
}
|
||||
|
||||
if (child->IsFile()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_DIR).FormatCause(child->GetFilePath().GetPath().c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH)
|
||||
.FormatCause(child->GetFilePath().GetPath().c_str(), "not a directory"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -217,7 +219,8 @@ bool ResourceAppend::ScanLimitKey(const unique_ptr<FileEntry> &entry,
|
||||
}
|
||||
|
||||
if (child->IsFile()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_DIR).FormatCause(child->GetFilePath().GetPath().c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH)
|
||||
.FormatCause(child->GetFilePath().GetPath().c_str(), "not a directory"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -248,7 +251,8 @@ bool ResourceAppend::ScanFiles(const unique_ptr<FileEntry> &entry,
|
||||
}
|
||||
|
||||
if (!child->IsFile()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_FILE).FormatCause(child->GetFilePath().GetPath().c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH)
|
||||
.FormatCause(child->GetFilePath().GetPath().c_str(), "not a file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -406,7 +410,7 @@ bool ResourceAppend::LoadResourceItem(const string &filePath)
|
||||
int32_t length = in.tellg();
|
||||
in.seekg(0, in.beg);
|
||||
if (length <= 0) {
|
||||
PrintError(GetError(ERR_CODE_FILE_EMPTY).FormatCause(filePath.c_str()));
|
||||
PrintError(GetError(ERR_CODE_READ_FILE_ERROR).FormatCause(filePath.c_str(), "file is empty"));
|
||||
return false;
|
||||
}
|
||||
char buffer[length];
|
||||
@@ -446,7 +450,7 @@ bool ResourceAppend::WriteRawFilesOrResFiles(const string &filePath, const strin
|
||||
{
|
||||
string::size_type pos = filePath.find(limit);
|
||||
if (pos == string::npos) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_FILE_PATH).FormatCause(filePath.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH).FormatCause(filePath.c_str(), "missing separator"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -478,8 +482,8 @@ bool ResourceAppend::Push(const shared_ptr<ResourceItem> &resourceItem)
|
||||
int64_t id = IdWorker::GetInstance().GenerateId(resourceItem->GetResType(), idName);
|
||||
if (id < 0) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_ID_NOT_DEFINED)
|
||||
.FormatCause(ResourceUtil::ResTypeToString(resourceItem->GetResType()).c_str(),
|
||||
resourceItem->GetName().c_str()));
|
||||
.FormatCause(resourceItem->GetName().c_str(),
|
||||
ResourceUtil::ResTypeToString(resourceItem->GetResType()).c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -663,7 +667,7 @@ bool ResourceAppend::LoadResourceItemWin(const string &filePath)
|
||||
HANDLE hFileMap = CreateFileMapping(hReadFile, nullptr, PAGE_READONLY, 0, fileSize, nullptr);
|
||||
if (hFileMap == INVALID_HANDLE_VALUE) {
|
||||
string errMsg = "create mapping error: " + to_string(GetLastError());
|
||||
PrintError(GetError(ERR_CODE_FILE_MAP_ERROR).FormatCause(errMsg.c_str()).SetPosition(filePath));
|
||||
PrintError(GetError(ERR_CODE_READ_FILE_ERROR).FormatCause(filePath.c_str(), errMsg.c_str()));
|
||||
CloseHandle(hReadFile);
|
||||
return result;
|
||||
}
|
||||
@@ -671,7 +675,7 @@ bool ResourceAppend::LoadResourceItemWin(const string &filePath)
|
||||
void* pBuffer = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0);
|
||||
if (pBuffer == nullptr) {
|
||||
string errMsg = "map view of file error: " + to_string(GetLastError());
|
||||
PrintError(GetError(ERR_CODE_FILE_MAP_ERROR).FormatCause(errMsg.c_str()).SetPosition(filePath));
|
||||
PrintError(GetError(ERR_CODE_READ_FILE_ERROR).FormatCause(filePath.c_str(), errMsg.c_str()));
|
||||
CloseHandle(hReadFile);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ bool ResourceDirectory::ScanResources(const string &resourcesDir, function<bool(
|
||||
}
|
||||
|
||||
if (it->IsFile()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_DIR).FormatCause(it->GetFilePath().GetPath().c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH)
|
||||
.FormatCause(it->GetFilePath().GetPath().c_str(), "not a directory"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -79,16 +80,12 @@ bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, c
|
||||
}
|
||||
|
||||
if (it->IsFile()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_PATH_NOT_DIR).FormatCause(dirPath.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH).FormatCause(dirPath.c_str(), "not a directory"));
|
||||
return false;
|
||||
}
|
||||
|
||||
ResType type = ResourceUtil::GetResTypeByDir(fileCluster);
|
||||
if (type == ResType::INVALID_RES_TYPE) {
|
||||
string array;
|
||||
for (auto item : g_fileClusterMap) {
|
||||
array.append("'" + item.first + "' ");
|
||||
}
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_DIR)
|
||||
.FormatCause(fileCluster.c_str(), ResourceUtil::GetAllResTypeDirs().c_str())
|
||||
.SetPosition(dirPath));
|
||||
|
||||
+27
-27
@@ -152,7 +152,7 @@ uint32_t CommonDumper::DumpRes(std::string &out) const
|
||||
std::unique_ptr<cJSON, std::function<void(cJSON*)>> root(cJSON_CreateObject(),
|
||||
[](cJSON* node) { cJSON_Delete(node); });
|
||||
if (!root) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for root object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for root object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (!bundleName_.empty() && !moduleName_.empty()) {
|
||||
@@ -167,7 +167,7 @@ uint32_t CommonDumper::DumpRes(std::string &out) const
|
||||
}
|
||||
cJSON *resource = cJSON_CreateArray();
|
||||
if (!resource) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR)
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR)
|
||||
.FormatCause("unable to create cJSON object for resource array"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ uint32_t CommonDumper::DumpRes(std::string &out) const
|
||||
}
|
||||
char *rawStr = cJSON_Print(root.get());
|
||||
if (!rawStr) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("covert json object to str failed"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("covert json object to str failed"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
out = rawStr;
|
||||
@@ -191,14 +191,14 @@ uint32_t CommonDumper::DumpRes(std::string &out) const
|
||||
uint32_t CommonDumper::AddKeyParamsToJson(const std::vector<KeyParam> &keyParams, cJSON *json) const
|
||||
{
|
||||
if (!json) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("add keyparam to null json object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("add keyparam to null json object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
for (const auto &keyParam : keyParams) {
|
||||
std::string valueStr = ResourceUtil::GetKeyParamValue(keyParam);
|
||||
cJSON *value = cJSON_CreateString(valueStr.c_str());
|
||||
if (!value) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for keyparam"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for keyparam"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(json, ResourceUtil::KeyTypeToStr(keyParam.keyType).c_str(), value);
|
||||
@@ -209,26 +209,26 @@ uint32_t CommonDumper::AddKeyParamsToJson(const std::vector<KeyParam> &keyParams
|
||||
uint32_t CommonDumper::AddItemCommonPropToJson(int32_t resId, const ResourceItem &item, cJSON* json) const
|
||||
{
|
||||
if (!json) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("add item common property to null json object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("add item common property to null json object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON *id = cJSON_CreateNumber(resId);
|
||||
if (!id) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for resource id"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for resource id"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "id", id);
|
||||
|
||||
cJSON *name = cJSON_CreateString(item.GetName().c_str());
|
||||
if (!name) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for resource name"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for resource name"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "name", name);
|
||||
|
||||
cJSON *type = cJSON_CreateString((ResourceUtil::ResTypeToString(item.GetResType())).c_str());
|
||||
if (!type) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for resource type"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for resource type"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "type", type);
|
||||
@@ -238,16 +238,16 @@ uint32_t CommonDumper::AddItemCommonPropToJson(int32_t resId, const ResourceItem
|
||||
uint32_t CommonDumper::AddResourceToJson(int64_t resId, const std::vector<ResourceItem> &items, cJSON *json) const
|
||||
{
|
||||
if (items.empty()) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("resource items is empty"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("resource items is empty"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (!json) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("add resource to null json object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("add resource to null json object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON *resource = cJSON_CreateObject();
|
||||
if (!resource) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for resource item"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for resource item"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToArray(json, resource);
|
||||
@@ -257,7 +257,7 @@ uint32_t CommonDumper::AddResourceToJson(int64_t resId, const std::vector<Resour
|
||||
cJSON *entryCount = cJSON_CreateNumber(items.size());
|
||||
if (!entryCount) {
|
||||
PrintError(
|
||||
GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for resource value count"));
|
||||
GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for resource value count"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(resource, "entryCount", entryCount);
|
||||
@@ -265,7 +265,7 @@ uint32_t CommonDumper::AddResourceToJson(int64_t resId, const std::vector<Resour
|
||||
cJSON *entryValues = cJSON_CreateArray();
|
||||
if (!resource) {
|
||||
PrintError(
|
||||
GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for resource value array"));
|
||||
GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for resource value array"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(resource, "entryValues", entryValues);
|
||||
@@ -273,7 +273,7 @@ uint32_t CommonDumper::AddResourceToJson(int64_t resId, const std::vector<Resour
|
||||
for (const ResourceItem &item : items) {
|
||||
cJSON *value = cJSON_CreateObject();
|
||||
if (!value) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR)
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR)
|
||||
.FormatCause("unable to create cJSON object for value item"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
@@ -291,12 +291,12 @@ uint32_t CommonDumper::AddResourceToJson(int64_t resId, const std::vector<Resour
|
||||
uint32_t CommonDumper::AddPairVauleToJson(const ResourceItem &item, cJSON *json) const
|
||||
{
|
||||
if (!json) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("add pair vaule to null json object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("add pair vaule to null json object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON *value = cJSON_CreateObject();
|
||||
if (!value) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for value object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for value object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "value", value);
|
||||
@@ -305,7 +305,7 @@ uint32_t CommonDumper::AddPairVauleToJson(const ResourceItem &item, cJSON *json)
|
||||
if (rawValues.size() % PAIR_SIZE != 0) {
|
||||
cJSON *parent = cJSON_CreateString(rawValues[0].c_str());
|
||||
if (!parent) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for parent"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for parent"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "parent", parent);
|
||||
@@ -314,7 +314,7 @@ uint32_t CommonDumper::AddPairVauleToJson(const ResourceItem &item, cJSON *json)
|
||||
for (; index < rawValues.size(); index += PAIR_SIZE) {
|
||||
cJSON *item = cJSON_CreateString(rawValues[index].c_str());
|
||||
if (!item) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR)
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR)
|
||||
.FormatCause("unable to create cJSON object for value item"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
@@ -326,13 +326,13 @@ uint32_t CommonDumper::AddPairVauleToJson(const ResourceItem &item, cJSON *json)
|
||||
uint32_t CommonDumper::AddValueToJson(const ResourceItem &item, cJSON *json) const
|
||||
{
|
||||
if (!json) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("add value to null json object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("add value to null json object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
if (item.IsArray()) {
|
||||
cJSON *values = cJSON_CreateArray();
|
||||
if (!values) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR)
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR)
|
||||
.FormatCause("unable to create cJSON object for value array"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ uint32_t CommonDumper::AddValueToJson(const ResourceItem &item, cJSON *json) con
|
||||
cJSON *valueItem = cJSON_CreateString(value.c_str());
|
||||
if (!valueItem) {
|
||||
PrintError(
|
||||
GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for value item"));
|
||||
GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for value item"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToArray(values, valueItem);
|
||||
@@ -355,7 +355,7 @@ uint32_t CommonDumper::AddValueToJson(const ResourceItem &item, cJSON *json) con
|
||||
std::string rawValue = std::string(reinterpret_cast<const char*>(item.GetData()), item.GetDataLength());
|
||||
cJSON *value = cJSON_CreateString(rawValue.c_str());
|
||||
if (!value) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for value"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for value"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "value", value);
|
||||
@@ -367,12 +367,12 @@ uint32_t ConfigDumper::DumpRes(std::string &out) const
|
||||
std::unique_ptr<cJSON, std::function<void(cJSON*)>> root(cJSON_CreateObject(),
|
||||
[](cJSON* node) { cJSON_Delete(node); });
|
||||
if (!root) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for root object"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for root object"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON *configs = cJSON_CreateArray();
|
||||
if (!configs) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for config array"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for config array"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(root.get(), "config", configs);
|
||||
@@ -388,7 +388,7 @@ uint32_t ConfigDumper::DumpRes(std::string &out) const
|
||||
cJSON *config = cJSON_CreateString(limitKey.c_str());
|
||||
if (!config) {
|
||||
PrintError(
|
||||
GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("unable to create cJSON object for limitkey"));
|
||||
GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("unable to create cJSON object for limitkey"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToArray(configs, config);
|
||||
@@ -396,7 +396,7 @@ uint32_t ConfigDumper::DumpRes(std::string &out) const
|
||||
}
|
||||
char *rawStr = cJSON_Print(root.get());
|
||||
if (!rawStr) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_JSON_ERROR).FormatCause("covert config json object to str failed"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("covert config json object to str failed"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
out = rawStr;
|
||||
|
||||
@@ -162,6 +162,9 @@ const std::vector<std::string> ResourceItem::SplitValue() const
|
||||
|
||||
void ResourceItem::CheckData()
|
||||
{
|
||||
if (GetDataLength() == 0) {
|
||||
return;
|
||||
}
|
||||
int8_t data[GetDataLength()];
|
||||
for (uint32_t i = 0; i < GetDataLength(); i++) {
|
||||
data[i] = GetData()[i];
|
||||
|
||||
+22
-15
@@ -121,11 +121,14 @@ uint32_t ResourcePack::InitModule()
|
||||
return moduleName_ == iter;
|
||||
});
|
||||
if (it == moduleNames.end()) {
|
||||
string buffer(" ");
|
||||
string buffer("[");
|
||||
for_each(moduleNames.begin(), moduleNames.end(), [&buffer](const auto &iter) {
|
||||
buffer.append(" " + iter + " ");
|
||||
});
|
||||
PrintError(GetError(ERR_CODE_MODULE_NAME_NOT_FOUND).FormatCause(moduleName_.c_str(), buffer.c_str()));
|
||||
buffer.append("\"" + iter + "\"").append(",");
|
||||
});
|
||||
buffer.pop_back();
|
||||
buffer.append("]");
|
||||
PrintError(GetError(ERR_CODE_MODULE_NAME_NOT_FOUND).FormatCause(moduleName_.c_str(), buffer.c_str())
|
||||
.SetPosition(configJson_.GetConfigFilePath()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -382,7 +385,6 @@ uint32_t ResourcePack::HandleFeature()
|
||||
int64_t labelId = entryJson.GetAbilityLabelId();
|
||||
int64_t iconId = entryJson.GetAbilityIconId();
|
||||
if (labelId <= 0 || iconId <= 0) {
|
||||
PrintError(ERR_CODE_FA_ENTRY_NO_ICON_LABEL);
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
string path = FileEntry::FilePath(featureDependEntry).Append(RESOURCE_INDEX_FILE).GetPath();
|
||||
@@ -419,13 +421,15 @@ uint32_t ResourcePack::FindResourceItems(const map<int64_t, vector<ResourceItem>
|
||||
{
|
||||
auto ret = resInfoLocal.find(id);
|
||||
if (ret == resInfoLocal.end()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_INDEX_ID_NOT_FOUND).FormatCause(id));
|
||||
string msg = "the id '" + std::to_string(id) + "' not found";
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause(msg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
ResType type = ResType::INVALID_RES_TYPE;
|
||||
items = ret->second;
|
||||
if (items.empty()) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_INDEX_ITEM_EMPTY).FormatCause(id));
|
||||
string msg = "the items of id '" + std::to_string(id) + "' is empty";
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause(msg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
for (auto &it : items) {
|
||||
@@ -435,7 +439,8 @@ uint32_t ResourcePack::FindResourceItems(const map<int64_t, vector<ResourceItem>
|
||||
if (type != it.GetResType()) {
|
||||
string typePre = ResourceUtil::ResTypeToString(type);
|
||||
string typeCur = ResourceUtil::ResTypeToString(it.GetResType());
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_INDEX_INVALID_RESTYPE).FormatCause(typeCur.c_str(), typePre.c_str()));
|
||||
string msg = "invalid restype '" + typePre + "', expected type is '" + typeCur + "'";
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause(msg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -448,9 +453,10 @@ uint32_t ResourcePack::HandleLabel(vector<ResourceItem> &items, ConfigParser &co
|
||||
string idName;
|
||||
for (auto it : items) {
|
||||
if (it.GetResType() != ResType::STRING) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_INDEX_INVALID_RESTYPE)
|
||||
.FormatCause(ResourceUtil::ResTypeToString(it.GetResType()).c_str(),
|
||||
ResourceUtil::ResTypeToString(ResType::STRING).c_str()));
|
||||
string typeCur = ResourceUtil::ResTypeToString(it.GetResType());
|
||||
string typeExpect = ResourceUtil::ResTypeToString(ResType::STRING);
|
||||
string msg = "invalid restype '" + typeCur + "', expected type is '" + typeExpect + "'";
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause(msg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
idName = it.GetName() + "_entry";
|
||||
@@ -499,15 +505,16 @@ uint32_t ResourcePack::HandleIcon(vector<ResourceItem> &items, ConfigParser &con
|
||||
string idName;
|
||||
for (auto it : items) {
|
||||
if (it.GetResType() != ResType::MEDIA) {
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_INDEX_INVALID_RESTYPE)
|
||||
.FormatCause(ResourceUtil::ResTypeToString(it.GetResType()).c_str(),
|
||||
ResourceUtil::ResTypeToString(ResType::MEDIA).c_str()));
|
||||
string typeCur = ResourceUtil::ResTypeToString(it.GetResType());
|
||||
string typeExpect = ResourceUtil::ResTypeToString(ResType::MEDIA);
|
||||
string msg = "invalid restype '" + typeCur + "', expected type is '" + typeExpect + "'";
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause(msg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
string dataPath(reinterpret_cast<const char *>(it.GetData()));
|
||||
string::size_type pos = dataPath.find_first_of(SEPARATOR);
|
||||
if (pos == string::npos) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_FILE_PATH).FormatCause(dataPath.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_PATH).FormatCause(dataPath.c_str(), "missing separator"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
dataPath = dataPath.substr(pos + 1);
|
||||
|
||||
+32
-29
@@ -112,7 +112,7 @@ uint32_t ResourceTable::LoadResTable(const string path, map<int64_t, vector<Reso
|
||||
int64_t length = in.tellg();
|
||||
if (length <= 0) {
|
||||
in.close();
|
||||
PrintError(GetError(ERR_CODE_FILE_EMPTY).FormatCause(path.c_str()));
|
||||
PrintError(GetError(ERR_CODE_READ_FILE_ERROR).FormatCause(path.c_str(), "file is empty"));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
in.seekg(0, ios::beg);
|
||||
@@ -124,7 +124,8 @@ uint32_t ResourceTable::LoadResTable(const string path, map<int64_t, vector<Reso
|
||||
uint32_t ResourceTable::LoadResTable(basic_istream<char> &in, map<int64_t, vector<ResourceItem>> &resInfos)
|
||||
{
|
||||
if (!in) {
|
||||
PrintError(GetError(ERR_CODE_FILE_STREAM_ERROR).FormatCause(in.rdstate()));
|
||||
std::string msg = "file stream bad, state code: " + std::to_string(in.rdstate());
|
||||
PrintError(GetError(ERR_CODE_READ_FILE_ERROR).FormatCause(in.rdstate(), msg.c_str()));
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
in.seekg(0, ios::end);
|
||||
@@ -161,23 +162,23 @@ uint32_t ResourceTable::CreateIdDefined(const map<int64_t, vector<ResourceItem>>
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
cJSON *recordArray = cJSON_CreateArray();
|
||||
if (recordArray == nullptr) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_ID_DEFINED_ERROR)
|
||||
.FormatCause(idDefinedPath_.c_str(), "failed to create cJSON object for record array"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("failed to create cJSON object for record array")
|
||||
.SetPosition(idDefinedPath_));
|
||||
cJSON_Delete(root);
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON_AddItemToObject(root, "record", recordArray);
|
||||
for (const auto &pairPtr : allResource) {
|
||||
if (pairPtr.second.empty()) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_ID_DEFINED_ERROR)
|
||||
.FormatCause(idDefinedPath_.c_str(), "resource item vector is empty"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("resource item vector is empty")
|
||||
.SetPosition(idDefinedPath_));
|
||||
cJSON_Delete(root);
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
cJSON *jsonItem = cJSON_CreateObject();
|
||||
if (jsonItem == nullptr) {
|
||||
PrintError(GetError(ERR_CODE_CREATE_ID_DEFINED_ERROR)
|
||||
.FormatCause(idDefinedPath_.c_str(), "failed to create cJSON object for resource item"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("failed to create cJSON object for resource item")
|
||||
.SetPosition(idDefinedPath_));
|
||||
cJSON_Delete(root);
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
@@ -189,8 +190,8 @@ uint32_t ResourceTable::CreateIdDefined(const map<int64_t, vector<ResourceItem>>
|
||||
if (type.empty()) {
|
||||
string errMsg = "name = ";
|
||||
errMsg.append(name);
|
||||
errMsg.append("invalid restype, type must in [").append(ResourceUtil::GetAllRestypeString()).append("]");
|
||||
PrintError(GetError(ERR_CODE_CREATE_ID_DEFINED_ERROR).FormatCause(idDefinedPath_.c_str(), errMsg.c_str()));
|
||||
errMsg.append("invalid restype, type must in ").append(ResourceUtil::GetAllRestypeString());
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause(errMsg.c_str()).SetPosition(idDefinedPath_));
|
||||
cJSON_Delete(jsonItem);
|
||||
cJSON_Delete(root);
|
||||
return RESTOOL_ERROR;
|
||||
@@ -248,7 +249,7 @@ uint32_t ResourceTable::SaveToResouorceIndex(const map<string, vector<TableData>
|
||||
bool ResourceTable::InitIndexHeader(IndexHeader &indexHeader, uint32_t count) const
|
||||
{
|
||||
if (memcpy_s(indexHeader.version, VERSION_MAX_LEN, RESTOOL_VERSION, VERSION_MAX_LEN) != EOK) {
|
||||
PrintError(GetError(ERR_CODE_MEMCPY_ERROR).FormatCause("InitIndexHeader"));
|
||||
PrintError(GetError(ERR_CODE_UNDEFINED_ERROR).FormatCause("memcpy error when init index header"));
|
||||
return false;
|
||||
}
|
||||
indexHeader.limitKeyConfigSize = count;
|
||||
@@ -298,15 +299,15 @@ bool ResourceTable::SaveRecordItem(const map<string, vector<TableData>> &configs
|
||||
for (const auto &config : configs) {
|
||||
auto idSet = idSets.find(config.first);
|
||||
if (idSet == idSets.end()) {
|
||||
string errMsg = "id set of limit key '" + config.first + "' not found";
|
||||
PrintError(GetError(ERR_CODE_SAVE_INDEX_ERROR).FormatCause(errMsg.c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_LIMIT_KEY).FormatCause(config.first.c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto &tableData : config.second) {
|
||||
if (idSet->second.data.find(tableData.id) == idSet->second.data.end()) {
|
||||
string errMsg = "the resource table id " + to_string(tableData.id) + " not found";
|
||||
PrintError(GetError(ERR_CODE_SAVE_INDEX_ERROR).FormatCause(errMsg.c_str()));
|
||||
string resType = ResourceUtil::ResTypeToString(tableData.resourceItem.GetResType());
|
||||
string name = tableData.resourceItem.GetName();
|
||||
PrintError(GetError(ERR_CODE_RESOURCE_ID_NOT_DEFINED).FormatCause(name.c_str(), resType.c_str()));
|
||||
return false;
|
||||
}
|
||||
idSet->second.data[tableData.id] = pos;
|
||||
@@ -368,7 +369,7 @@ bool ResourceTable::ReadFileHeader(basic_istream<char> &in, IndexHeader &indexHe
|
||||
{
|
||||
pos += sizeof(indexHeader);
|
||||
if (pos > length) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("file header"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("header length error"));
|
||||
return false;
|
||||
}
|
||||
in.read(reinterpret_cast<char *>(indexHeader.version), VERSION_MAX_LEN);
|
||||
@@ -383,14 +384,15 @@ bool ResourceTable::ReadLimitKeys(basic_istream<char> &in, map<int64_t, vector<K
|
||||
for (uint32_t i = 0; i< count; i++) {
|
||||
pos = pos + TAG_LEN + INT_TO_BYTES + INT_TO_BYTES;
|
||||
if (pos > length) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("KEYS"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("KEYS length error"));
|
||||
return false;
|
||||
}
|
||||
LimitKeyConfig limitKey;
|
||||
in.read(reinterpret_cast<char *>(limitKey.keyTag), TAG_LEN);
|
||||
string keyTag(reinterpret_cast<const char *>(limitKey.keyTag), TAG_LEN);
|
||||
if (keyTag != "KEYS") {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause(string("key tag = " + keyTag).c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX)
|
||||
.FormatCause(string("invalid key tag = " + keyTag).c_str()));
|
||||
return false;
|
||||
}
|
||||
in.read(reinterpret_cast<char *>(&limitKey.offset), INT_TO_BYTES);
|
||||
@@ -400,7 +402,7 @@ bool ResourceTable::ReadLimitKeys(basic_istream<char> &in, map<int64_t, vector<K
|
||||
for (uint32_t j = 0; j < limitKey.keyCount; j++) {
|
||||
pos = pos + INT_TO_BYTES + INT_TO_BYTES;
|
||||
if (pos > length) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("keyParams"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("keyParams length error"));
|
||||
return false;
|
||||
}
|
||||
KeyParam keyParam;
|
||||
@@ -419,7 +421,7 @@ bool ResourceTable::ReadIdTables(basic_istream<char> &in, std::map<int64_t, std:
|
||||
for (uint32_t i = 0; i< count; i++) {
|
||||
pos = pos + TAG_LEN + INT_TO_BYTES;
|
||||
if (pos > length) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("IDSS"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("IDSS length error"));
|
||||
return false;
|
||||
}
|
||||
IdSet idss;
|
||||
@@ -427,7 +429,8 @@ bool ResourceTable::ReadIdTables(basic_istream<char> &in, std::map<int64_t, std:
|
||||
in.read(reinterpret_cast<char *>(idss.idTag), TAG_LEN);
|
||||
string idTag(reinterpret_cast<const char *>(idss.idTag), TAG_LEN);
|
||||
if (idTag != "IDSS") {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause(string("id tag = " + idTag).c_str()));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX)
|
||||
.FormatCause(string("invalid id tag = " + idTag).c_str()));
|
||||
return false;
|
||||
}
|
||||
in.read(reinterpret_cast<char *>(&idss.idCount), INT_TO_BYTES);
|
||||
@@ -435,7 +438,7 @@ bool ResourceTable::ReadIdTables(basic_istream<char> &in, std::map<int64_t, std:
|
||||
for (uint32_t j = 0; j < idss.idCount; j++) {
|
||||
pos = pos + INT_TO_BYTES + INT_TO_BYTES;
|
||||
if (pos > length) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("id data"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("id data length error"));
|
||||
return false;
|
||||
}
|
||||
IdData data;
|
||||
@@ -451,13 +454,13 @@ bool ResourceTable::ReadDataRecordPrepare(basic_istream<char> &in, RecordItem &r
|
||||
{
|
||||
pos = pos + INT_TO_BYTES;
|
||||
if (pos > length) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("data record"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("data record length error"));
|
||||
return false;
|
||||
}
|
||||
in.read(reinterpret_cast<char *>(&record.size), INT_TO_BYTES);
|
||||
pos = pos + record.size;
|
||||
if (pos > length) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("record.size"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("record.size length error"));
|
||||
return false;
|
||||
}
|
||||
in.read(reinterpret_cast<char *>(&record.resType), INT_TO_BYTES);
|
||||
@@ -475,7 +478,7 @@ bool ResourceTable::ReadDataRecordStart(basic_istream<char> &in, RecordItem &rec
|
||||
uint16_t value_size = 0;
|
||||
in.read(reinterpret_cast<char *>(&value_size), sizeof(uint16_t));
|
||||
if (value_size + sizeof(uint16_t) > record.size) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("value size"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("value size error"));
|
||||
return false;
|
||||
}
|
||||
int8_t values[value_size];
|
||||
@@ -484,7 +487,7 @@ bool ResourceTable::ReadDataRecordStart(basic_istream<char> &in, RecordItem &rec
|
||||
uint16_t name_size = 0;
|
||||
in.read(reinterpret_cast<char *>(&name_size), sizeof(uint16_t));
|
||||
if (value_size + sizeof(uint16_t) + name_size + sizeof(uint16_t) > record.size) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("name size"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("name size error"));
|
||||
return false;
|
||||
}
|
||||
int8_t name[name_size];
|
||||
@@ -493,17 +496,17 @@ bool ResourceTable::ReadDataRecordStart(basic_istream<char> &in, RecordItem &rec
|
||||
|
||||
auto idTableOffset = datas.find(offset);
|
||||
if (idTableOffset == datas.end()) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("id offset"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("invalid id offset"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (idTableOffset->second.first != record.id) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("id"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("invalid id"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (limitKeys.find(idTableOffset->second.second) == limitKeys.end()) {
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("limit key offset"));
|
||||
PrintError(GetError(ERR_CODE_INVALID_RESOURCE_INDEX).FormatCause("invalid limit key offset"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,10 +124,12 @@ ResType ResourceUtil::GetResTypeByDir(const string &name)
|
||||
|
||||
string ResourceUtil::GetAllResTypeDirs()
|
||||
{
|
||||
string dirs;
|
||||
string dirs = "[";
|
||||
for (auto iter = g_fileClusterMap.begin(); iter != g_fileClusterMap.end(); ++iter) {
|
||||
dirs.append(iter->first + ", ");
|
||||
dirs.append("\"").append(iter->first).append("\",");
|
||||
}
|
||||
dirs.pop_back();
|
||||
dirs.append("]");
|
||||
return dirs;
|
||||
}
|
||||
|
||||
@@ -394,10 +396,12 @@ bool ResourceUtil::CheckHexStr(const string &hex)
|
||||
|
||||
string ResourceUtil::GetAllRestypeString()
|
||||
{
|
||||
string result;
|
||||
string result = "[";
|
||||
for (auto iter = g_contentClusterMap.begin(); iter != g_contentClusterMap.end(); ++iter) {
|
||||
result = result + "," + iter->first;
|
||||
result.append("\"").append(iter->first).append("\"").append(",");
|
||||
}
|
||||
result.pop_back();
|
||||
result.append("]");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+134
-224
@@ -21,11 +21,15 @@ namespace OHOS {
|
||||
namespace Global {
|
||||
namespace Restool {
|
||||
const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
|
||||
// 11200000
|
||||
{ ERR_CODE_UNDEFINED_ERROR,
|
||||
{ ERR_CODE_UNDEFINED_ERROR, "Undefined Error", "Unknown error: %s", "", { "Please try again." }, {} } },
|
||||
|
||||
// 11201xxx
|
||||
{ ERR_CODE_LOAD_LIBRARY_FAIL,
|
||||
{ ERR_CODE_LOAD_LIBRARY_FAIL,
|
||||
ERR_TYPE_DEPENDENCY,
|
||||
"Load library failed, path: '%s', %s",
|
||||
"Failed to load the library '%s', %s",
|
||||
"",
|
||||
{ "Make sure the library path is correct and has access permissions." },
|
||||
{} } },
|
||||
@@ -34,14 +38,14 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
|
||||
{ ERR_CODE_OPEN_JSON_FAIL,
|
||||
{ ERR_CODE_OPEN_JSON_FAIL,
|
||||
ERR_TYPE_CONFIG,
|
||||
"Open json file '%s' failed, %s.",
|
||||
"Failed to open the JSON file '%s', %s.",
|
||||
"",
|
||||
{ "Make sure the json file path is correct and has access permissions." },
|
||||
{ "Make sure the JSON file path is correct and has access permissions." },
|
||||
{} } },
|
||||
{ ERR_CODE_JSON_FORMAT_ERROR,
|
||||
{ ERR_CODE_JSON_FORMAT_ERROR,
|
||||
ERR_TYPE_CONFIG,
|
||||
"Parse json file failed, please check the file.",
|
||||
"Failed to parse the JSON file, format is incorrect.",
|
||||
"",
|
||||
{ "Check the JSON file and delete unnecessary commas (,).",
|
||||
"Check the JSON file to make sure the root bracket is {}." },
|
||||
@@ -49,7 +53,7 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
|
||||
{ ERR_CODE_JSON_NODE_MISMATCH,
|
||||
{ ERR_CODE_JSON_NODE_MISMATCH,
|
||||
ERR_TYPE_CONFIG,
|
||||
"Parse json file failed, the '%s' node type mismatch, expected type: '%s'.",
|
||||
"The value type of node '%s' does not match, expected type: %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
@@ -60,261 +64,247 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
|
||||
{ ERR_CODE_JSON_NOT_ONE_MEMBER,
|
||||
{ ERR_CODE_JSON_NOT_ONE_MEMBER,
|
||||
ERR_TYPE_CONFIG,
|
||||
"The node '%s' of the json file can only have one member.",
|
||||
"The node '%s' of the JSON file can only have one member.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_JSON_INVALID_NODE_NAME,
|
||||
{ ERR_CODE_JSON_INVALID_NODE_NAME, ERR_TYPE_CONFIG, "Invalid node name '%s'.", "", {}, {} } },
|
||||
{ ERR_CODE_JSON_INVALID_NODE_NAME,
|
||||
ERR_TYPE_CONFIG,
|
||||
"Invalid node name '%s', it should be one of %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
|
||||
// 11204xxx
|
||||
{ ERR_CODE_CREATE_FILE_ERROR,
|
||||
{ ERR_CODE_CREATE_FILE_ERROR,
|
||||
ERR_TYPE_FILE_RESOURCE,
|
||||
"Create directory or file '%s' failed, %s.",
|
||||
"Failed to create directory or file '%s', %s.",
|
||||
"",
|
||||
{ "Make sure the file path is correct and has access permissions." },
|
||||
{} } },
|
||||
{ ERR_CODE_FILE_NOT_EXIST,
|
||||
{ ERR_CODE_FILE_NOT_EXIST,
|
||||
ERR_TYPE_FILE_RESOURCE,
|
||||
"File not exists, '%s'.",
|
||||
"",
|
||||
{ "Make sure the file path is correct." },
|
||||
{} } },
|
||||
{ ERR_CODE_REMOVE_FILE_ERROR,
|
||||
{ ERR_CODE_REMOVE_FILE_ERROR,
|
||||
ERR_TYPE_FILE_RESOURCE,
|
||||
"Remove dir/file '%s' failed, %s.",
|
||||
"Failed to delete directory or file '%s', %s.",
|
||||
"",
|
||||
{ "Make sure the file path is correct." },
|
||||
{ "Make sure the file path is correct and has access permissions." },
|
||||
{} } },
|
||||
{ ERR_CODE_COPY_FILE_ERROR,
|
||||
{ ERR_CODE_COPY_FILE_ERROR,
|
||||
ERR_TYPE_FILE_RESOURCE,
|
||||
"Copy file from '%s' to '%s' failed, %s.",
|
||||
"Failed to copy file from '%s' to '%s', %s.",
|
||||
"",
|
||||
{ "Make sure the src and dest file path is correct and has access permissions." },
|
||||
{} } },
|
||||
{ ERR_CODE_OPEN_FILE_ERROR,
|
||||
{ ERR_CODE_OPEN_FILE_ERROR,
|
||||
ERR_TYPE_FILE_RESOURCE,
|
||||
"Open file failed '%s', %s.",
|
||||
"Failed to open file '%s', %s.",
|
||||
"",
|
||||
{ "Make sure the src and dest file path is correct and has access permissions." },
|
||||
{ "Make sure the file path is correct and has access permissions." },
|
||||
{} } },
|
||||
{ ERR_CODE_FILE_EMPTY, { ERR_CODE_FILE_EMPTY, ERR_TYPE_FILE_RESOURCE, "File is empty '%s'.", "", {}, {} } },
|
||||
{ ERR_CODE_FILE_STREAM_ERROR,
|
||||
{ ERR_CODE_FILE_STREAM_ERROR, ERR_TYPE_FILE_RESOURCE, "File stream bad, state code: %d.", "", {}, {} } },
|
||||
{ ERR_CODE_FILE_MAP_ERROR,
|
||||
{ ERR_CODE_FILE_MAP_ERROR, ERR_TYPE_FILE_RESOURCE, "File mapping failed, %s.", "", {}, {} } },
|
||||
|
||||
// 11205xxx
|
||||
{ ERR_CODE_SET_DATA_ERROR,
|
||||
{ ERR_CODE_SET_DATA_ERROR,
|
||||
ERR_TYPE_SYNTAX,
|
||||
"Set resource item data of '%s' failed, it may be due to insufficient memory.",
|
||||
{ ERR_CODE_READ_FILE_ERROR,
|
||||
{ ERR_CODE_READ_FILE_ERROR,
|
||||
ERR_TYPE_FILE_RESOURCE,
|
||||
"Failed to read file '%s', %s.",
|
||||
"",
|
||||
{ "Retry compile." },
|
||||
{} } },
|
||||
{ ERR_CODE_ITEM_DATA_NULL,
|
||||
{ ERR_CODE_ITEM_DATA_NULL,
|
||||
ERR_TYPE_SYNTAX,
|
||||
"Get resource item data of '%s' failed, null.",
|
||||
"",
|
||||
{ "Retry compile." },
|
||||
{} } },
|
||||
{ ERR_CODE_MEMCPY_ERROR,
|
||||
{ ERR_CODE_MEMCPY_ERROR, ERR_TYPE_SYNTAX, "Memory copy failed in '%s'.", "", { "Retry compile." }, {} } },
|
||||
{ ERR_CODE_CREATE_JSON_ERROR,
|
||||
{ ERR_CODE_CREATE_JSON_ERROR,
|
||||
ERR_TYPE_SYNTAX,
|
||||
"Generate JSON failed, %s.",
|
||||
"",
|
||||
{ "Run the command again." },
|
||||
{ "Make sure the file content is correct." },
|
||||
{} } },
|
||||
|
||||
// 11210xxx
|
||||
{ ERR_CODE_UNKNOWN_COMMAND_ERROR,
|
||||
{ ERR_CODE_UNKNOWN_COMMAND_ERROR,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Unknown error: %s",
|
||||
"Unknown command error: %s",
|
||||
"",
|
||||
{ "For details, see the help with option -h/--help." },
|
||||
{} } },
|
||||
{ ERR_CODE_UNKNOWN_OPTION,
|
||||
{ ERR_CODE_UNKNOWN_OPTION,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Unknown option: '%s'",
|
||||
"Unknown option '%s'.",
|
||||
"",
|
||||
{ "For details, see the help with option -h/--help." },
|
||||
{} } },
|
||||
{ ERR_CODE_MISSING_ARGUMENT,
|
||||
{ ERR_CODE_MISSING_ARGUMENT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Option '%s' must have argument",
|
||||
"Option '%s' should have a argument.",
|
||||
"",
|
||||
{ "For details, see the help with option -h/--help." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_ARGUMENT,
|
||||
{ ERR_CODE_INVALID_ARGUMENT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Invalid arguments : '%s'",
|
||||
"Invalid argument value '%s'.",
|
||||
"",
|
||||
{ "For details, see the help with option -h/--help." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_INPUT,
|
||||
{ ERR_CODE_INVALID_INPUT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Invalid input '%s'",
|
||||
"Invalid input path '%s'.",
|
||||
"",
|
||||
{ "Make sure the input path of option -i/--inputPath is correct." },
|
||||
{} } },
|
||||
{ ERR_CODE_DUPLICATE_INPUT,
|
||||
{ ERR_CODE_DUPLICATE_INPUT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Duplicated input '%s'",
|
||||
"Duplicated input path '%s'.",
|
||||
"",
|
||||
{ "Make sure the input path of option -i/--inputPath is unique." },
|
||||
{} } },
|
||||
{ ERR_CODE_DOUBLE_PACKAGE_NAME,
|
||||
{ ERR_CODE_DOUBLE_PACKAGE_NAME,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Double package name '%s' vs '%s'",
|
||||
"The package name '%s' and '%s' conflict.",
|
||||
"",
|
||||
{ "Make sure the option -p/--packageName only specified once." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_OUTPUT,
|
||||
{ ERR_CODE_INVALID_OUTPUT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Invalid output '%s'",
|
||||
"Invalid output path '%s'.",
|
||||
"",
|
||||
{ "Make sure the output path of option -o/--outputPath is correct." },
|
||||
{} } },
|
||||
{ ERR_CODE_DOUBLE_OUTPUT,
|
||||
{ ERR_CODE_DOUBLE_OUTPUT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Double output '%s' vs '%s'",
|
||||
"The output path '%s' and '%s' conflict.",
|
||||
"",
|
||||
{ "Make sure the option -o/--outputPath only specified once." },
|
||||
{} } },
|
||||
{ ERR_CODE_DUPLICATE_RES_HEADER,
|
||||
{ ERR_CODE_DUPLICATE_RES_HEADER,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Duplicated res header path '%s'",
|
||||
"Duplicated res header path '%s'.",
|
||||
"",
|
||||
{ "Make sure the path of option -r/--resHeader is unique." },
|
||||
{} } },
|
||||
{ ERR_CODE_DOUBLE_MODULES,
|
||||
{ ERR_CODE_DOUBLE_MODULES,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Double module name '%s'",
|
||||
"The module name '%s' and '%s' conflict.",
|
||||
"",
|
||||
{ "Make sure the option -m/--modules only specified once." },
|
||||
{} } },
|
||||
{ ERR_CODE_DUPLICATE_MODULE_NAME,
|
||||
{ ERR_CODE_DUPLICATE_MODULE_NAME,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Duplicated module name '%s'",
|
||||
"Duplicated module name '%s'.",
|
||||
"",
|
||||
{ "Make sure the module name is unique." },
|
||||
{ "Make sure the module names specified with option -m/--modules is unique." },
|
||||
{} } },
|
||||
{ ERR_CODE_DOUBLE_CONFIG_JSON,
|
||||
{ ERR_CODE_DOUBLE_CONFIG_JSON,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Double config json '%s' vs '%s'",
|
||||
"The module.json(in Stage Model) or config.json(in FA Model) path '%s' and '%s' conflict.",
|
||||
"",
|
||||
{ "Make sure the option -j/--json only specified once." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_START_ID,
|
||||
{ ERR_CODE_INVALID_START_ID,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Invalid start id '%s'",
|
||||
"Invalid start id '%s', out of range.",
|
||||
"",
|
||||
{ "Make sure the start id in the scope [0x01000000, 0x06FFFFFF) or [0x08000000, 0xFFFFFFFF)" },
|
||||
{ "Make sure the start id in the scope [0x01000000, 0x06FFFFFF) or [0x08000000, 0xFFFFFFFF)." },
|
||||
{} } },
|
||||
{ ERR_CODE_DUPLICATE_APPEND_PATH,
|
||||
{ ERR_CODE_DUPLICATE_APPEND_PATH,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Duplicated input append path '%s'",
|
||||
"Duplicated append path '%s'.",
|
||||
"",
|
||||
{ "Make sure the path of option -x/--append is unique." },
|
||||
{} } },
|
||||
{ ERR_CODE_DOUBLE_TARGET_CONFIG,
|
||||
{ ERR_CODE_DOUBLE_TARGET_CONFIG,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Double option '--target-config'",
|
||||
"The target config '%s' and '%s' conflict.",
|
||||
"",
|
||||
{ "Make sure the option --target-config only specified once." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_TARGET_CONFIG,
|
||||
{ ERR_CODE_INVALID_TARGET_CONFIG,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Invalid target config argument '%s'",
|
||||
"Invalid target config argument '%s'.The argument format of option --target-config is supposed to be like "
|
||||
"'Locale[zh_CN,en_US];Device[phone]'.",
|
||||
"",
|
||||
{ "The argument format of option --target-config is supposed to be like 'Locale[zh_CN,en_US];Device[phone]', "
|
||||
"for details, see the developer documentation." },
|
||||
{ "For more information, see the developer documentation." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_SYSTEM_ID_DEFINED,
|
||||
{ ERR_CODE_INVALID_SYSTEM_ID_DEFINED,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Invalid system id_defined.json path '%s'",
|
||||
"Invalid system id_defined.json path '%s'.",
|
||||
"",
|
||||
{ "Make sure the system id_defined.json path is correct." },
|
||||
{} } },
|
||||
{ ERR_CODE_DUPLICATE_SYSTEM_ID_DEFINED,
|
||||
{ ERR_CODE_DUPLICATE_SYSTEM_ID_DEFINED,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Duplicated system id_defined.json path '%s'",
|
||||
"Duplicated system id_defined.json path '%s'.",
|
||||
"",
|
||||
{ "Make sure the system id_defined.json path is unique." },
|
||||
{} } },
|
||||
{ ERR_CODE_DOUBLE_COMPRESSION_PATH,
|
||||
{ ERR_CODE_DOUBLE_COMPRESSION_PATH,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Double compression json path '%s' vs '%s'",
|
||||
"The compression JSON path '%s' and '%s' conflict.",
|
||||
"",
|
||||
{ "Make sure the option --compressed-config only specified once." },
|
||||
{} } },
|
||||
{ ERR_CODE_NON_ASCII,
|
||||
{ ERR_CODE_NON_ASCII,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"'%s' must be ASCII",
|
||||
"The argument value '%s' is not an ASCII value.",
|
||||
"",
|
||||
{ "Make sure all the argument's characters is ASCII." },
|
||||
{ "Make sure all the arguments value characters is ASCII." },
|
||||
{} } },
|
||||
{ ERR_CODE_EXCLUSIVE_OPTION,
|
||||
{ ERR_CODE_EXCLUSIVE_OPTION, ERR_TYPE_COMMAND_PARSE, "Option %s and %s cannot be used together.", "", {}, {} } },
|
||||
{ ERR_CODE_EXCLUSIVE_OPTION,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Option '%s' and '%s' cannot be used together.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_PACKAGE_NAME_EMPTY,
|
||||
{ ERR_CODE_PACKAGE_NAME_EMPTY,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Package name empty.",
|
||||
"The package name is empty, it should be specified with option -p/--packageName",
|
||||
"",
|
||||
{ "Specifies the package name with option -p/--packageName." },
|
||||
{} } },
|
||||
{ ERR_CODE_RES_HEADER_PATH_EMPTY,
|
||||
{ ERR_CODE_RES_HEADER_PATH_EMPTY,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Resource header path empty.",
|
||||
"The resource header path(like ./ResourceTable.js, ./ResrouceTable.h) is empty, it should be specified with "
|
||||
"option -r/--resHeader.",
|
||||
"",
|
||||
{ "Specifies header path with option -r/--resHeader." },
|
||||
{} } },
|
||||
{ ERR_CODE_DUMP_MISSING_INPUT,
|
||||
{ ERR_CODE_DUMP_MISSING_INPUT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Resource dump missing input path.",
|
||||
"The HAP path of the resource dump command is missing.",
|
||||
"",
|
||||
{ "Specifies input path after dump command." },
|
||||
{ "Specifies a HAP path with dump command." },
|
||||
{} } },
|
||||
{ ERR_CODE_DUMP_INVALID_INPUT,
|
||||
{ ERR_CODE_DUMP_INVALID_INPUT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Resource dump invalid input path.",
|
||||
"Invalid HAP path '%s' of the resource dump command.",
|
||||
"",
|
||||
{ "Make sure the input path after dump command is correct." },
|
||||
{ "Make sure the HAP path of dump command is correct." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_THREAD_COUNT,
|
||||
{ ERR_CODE_INVALID_THREAD_COUNT, ERR_TYPE_COMMAND_PARSE, "Invalid thread count: %s.", "", {}, {} } },
|
||||
{ ERR_CODE_INVALID_THREAD_COUNT,
|
||||
ERR_TYPE_COMMAND_PARSE,
|
||||
"Invalid thread count '%s', it should be an integer and greater than 0.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
|
||||
// 11211xxx
|
||||
{ ERR_CODE_OUTPUT_EXIST,
|
||||
@@ -327,281 +317,201 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
|
||||
{ ERR_CODE_CONFIG_JSON_MISSING,
|
||||
{ ERR_CODE_CONFIG_JSON_MISSING,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"More input path, but -j config.json not specified.",
|
||||
"Multiple input paths, but the module.json(in Stage Model) or config.json(in FA Model) path is not specified "
|
||||
"with option -j/--json.",
|
||||
"",
|
||||
{ "Specifies the config.json with option -j/--json." },
|
||||
{ "Specifies option -j/--json." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_MODULE_TYPE,
|
||||
{ ERR_CODE_INVALID_MODULE_TYPE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid module type '%s', expected type is one of [entry, har, shared, feature].",
|
||||
"Invalid module type '%s', it should be one of [\"entry\", \"har\", \"shared\", \"feature\"].",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_EXCLUSIVE_START_ID,
|
||||
{ ERR_CODE_EXCLUSIVE_START_ID,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The set start_id and id_defined.json cannot be used together.",
|
||||
"The id_defined.json and the start id '%lu' specified with option -e/--startId conflict.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_NODE_MISSING,
|
||||
{ ERR_CODE_ID_DEFINED_NODE_MISSING,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json seq = %lu %s empty.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_NODE_MISMATCH,
|
||||
{ ERR_CODE_ID_DEFINED_NODE_MISMATCH,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json seq = %lu %s not %s.",
|
||||
"",
|
||||
{},
|
||||
{ "Retain only one of the id_defined.json and the start id." },
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_INVALID_TYPE,
|
||||
{ ERR_CODE_ID_DEFINED_INVALID_TYPE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json seq = %lu type '%s' invalid.",
|
||||
"Invalid resource type '%s' in the id_defined.json, it should be one of %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_INVALID_ID,
|
||||
{ ERR_CODE_ID_DEFINED_INVALID_ID,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json seq = %lu id must be a hex string, eg:^0[xX][0-9a-fA-F]{8}.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_ID_OUT_RANGE,
|
||||
{ ERR_CODE_ID_DEFINED_ID_OUT_RANGE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json seq = %lu id must in [0x01000000,0x06FFFFFF],[0x08000000,0xFFFFFFFF].",
|
||||
"Invalid id value '%s' in the id_defined.json, it shoud be a hex string, match the pattern "
|
||||
"^0[xX][0-9a-fA-F]{8}, and in the scope [0x01000000,0x06FFFFFF] or [0x08000000,0xFFFFFFFF].",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_ORDER_MISMATCH,
|
||||
{ ERR_CODE_ID_DEFINED_ORDER_MISMATCH,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json seq = %lu order value %lu vs expect %lu.",
|
||||
"The order value '%lu' in the id_defined.json does not match the record element sequence '%lu', "
|
||||
"expected value: %lu.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_INVALID_START_ID,
|
||||
{ ERR_CODE_ID_DEFINED_INVALID_START_ID,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json 'startId' is invalid.",
|
||||
"",
|
||||
{},
|
||||
{ "Make sure the order value is same as the sequence." },
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_SAME_ID,
|
||||
{ ERR_CODE_ID_DEFINED_SAME_ID,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The id_defined.json '%s' and '%s' defind the same ID.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ID_DEFINED_SAME_RESOURCE,
|
||||
{ ERR_CODE_ID_DEFINED_SAME_RESOURCE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The same resource of '%s' exists in the %s",
|
||||
"The name '%s' and '%s' in the id_defined.json define the same ID.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_MODULE_NAME_NOT_FOUND,
|
||||
{ ERR_CODE_MODULE_NAME_NOT_FOUND,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The module name '%s' in config.json not found in [%s] which specifies with -m/--modules.",
|
||||
"The module name '%s' not found in %s, which specifies with -m/--modules.",
|
||||
"",
|
||||
{ "Make sure the module name in config.json is correct." },
|
||||
{ "Make sure the module name in module.json(in Stage Model) or config.json(in FA Model) is correct." },
|
||||
{} } },
|
||||
{ ERR_CODE_RESOURCE_PATH_NOT_DIR,
|
||||
{ ERR_CODE_RESOURCE_PATH_NOT_DIR,
|
||||
{ ERR_CODE_INVALID_RESOURCE_PATH,
|
||||
{ ERR_CODE_INVALID_RESOURCE_PATH,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Scan resource failed, the path '%s' is not directory.",
|
||||
"Failed to scan resources, invalid path '%s', %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_FILE_PATH,
|
||||
{ ERR_CODE_INVALID_FILE_PATH,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid file path '%s'.",
|
||||
"",
|
||||
{ "Make sure the path is correct." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_LIMIT_KEY,
|
||||
{ ERR_CODE_INVALID_LIMIT_KEY, ERR_TYPE_RESOURCE_PACK, "Invalid limit key '%s'.", "", {}, {} } },
|
||||
{ ERR_CODE_INVALID_LIMIT_KEY,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid qualifiers key '%s', it should match the pattern of qualifiers directory,for example zh_CN,en_US,etc.",
|
||||
"",
|
||||
{ "For more information, see the developer documentation." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_RESOURCE_DIR,
|
||||
{ ERR_CODE_INVALID_RESOURCE_DIR,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid resource directory name '%s', must in [%s].",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_RESOURCE_PATH_NOT_FILE,
|
||||
{ ERR_CODE_RESOURCE_PATH_NOT_FILE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Scan resource failed, the resource '%s' must be a file.",
|
||||
"Invalid resource directory name '%s', it should be one of %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_TRANSLATE_PRIORITY,
|
||||
{ ERR_CODE_INVALID_TRANSLATE_PRIORITY,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid translate priority value '%s', must in [%s].",
|
||||
"Invalid translate priority value '%s', it should be one of %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_ELEMENT_TYPE,
|
||||
{ ERR_CODE_INVALID_ELEMENT_TYPE, ERR_TYPE_RESOURCE_PACK, "Unsupport element resource type '%s'.", "", {}, {} } },
|
||||
{ ERR_CODE_INVALID_ELEMENT_TYPE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Unsupported element resource type '%s', it should be one of %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_COLOR_VALUE,
|
||||
{ ERR_CODE_INVALID_COLOR_VALUE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid color value '%s', only support refer '$color:xxx' or '#rgb','#argb','#rrggbb','#aarrggbb'.",
|
||||
"Invalid color value '%s' of the resource '%s', it only supported reference '$color:xxx' or '#rgb','#argb',"
|
||||
"'#rrggbb','#aarrggbb'.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_RESOURCE_REF,
|
||||
{ ERR_CODE_INVALID_RESOURCE_REF,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid resource reference '%s', only support refer '%sxxx'.",
|
||||
"Invalid resource reference '%s', it only supported reference '%sxxx'.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_PARENT_EMPTY,
|
||||
{ ERR_CODE_PARENT_EMPTY,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The resource's parent is emptry, type: '%s', name: '%s'.",
|
||||
"The parent value of resource '%s' is empty, it should be a valid resource name.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ARRAY_TOO_LARGE,
|
||||
{ ERR_CODE_ARRAY_TOO_LARGE, ERR_TYPE_RESOURCE_PACK, "The array resource '%s' is to large.", "", {}, {} } },
|
||||
{ ERR_CODE_ARRAY_TOO_LARGE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The array resource '%s' is to large, the total length of the value of the array elements cannot exceed 65535.",
|
||||
"",
|
||||
{ "Separate the large array into multiple arrays." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_QUANTITY,
|
||||
{ ERR_CODE_INVALID_QUANTITY,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid quantity resource, name: '%s', quantity: '%s', the quantity must be one of [%s].",
|
||||
"Invalid quantity '%s' of the resource '%s', it should be one of %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_DUPLICATE_QUANTITY,
|
||||
{ ERR_CODE_DUPLICATE_QUANTITY,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Duplicated quantity resource, name: '%s', quantity: '%s'.",
|
||||
"Duplicated quantity '%s' of the plural resource '%s'.",
|
||||
"",
|
||||
{},
|
||||
{ "Make sure the quantity of the plural resource is unique." },
|
||||
{} } },
|
||||
{ ERR_CODE_QUANTITY_NO_OTHER,
|
||||
{ ERR_CODE_QUANTITY_NO_OTHER,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The quantity resource '%s' must contains 'other' quantity.",
|
||||
"The plural resource '%s' should contains 'other' quantity.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_SYMBOL,
|
||||
{ ERR_CODE_INVALID_SYMBOL,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The symbol resource '%s' invalid, value must in 0xF0000 ~ 0xFFFFF or 0x100000 ~ 0x10FFFF.",
|
||||
"Invalid value '%d' of the symbol resource '%s', it should be in the scope [0xF0000,0xFFFFF] or "
|
||||
"[0x100000,0x10FFFF].",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_RESOURCE_NAME,
|
||||
{ ERR_CODE_INVALID_RESOURCE_NAME,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Invalid resource name '%s', the name can only contain [a-zA-Z0-9_].",
|
||||
"Invalid resource name '%s', it should be match the pattern [a-zA-Z0-9_].",
|
||||
"",
|
||||
{ "Modify the name to match [a-zA-Z0-9_]." },
|
||||
{ "Modify the name to match the pattern [a-zA-Z0-9_]." },
|
||||
{} } },
|
||||
{ ERR_CODE_RESOURCE_DUPLICATE,
|
||||
{ ERR_CODE_RESOURCE_DUPLICATE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Resource '%s' conflict, first declared at %s, but declare again at %s.",
|
||||
"Resource '%s' conflict, first declared at '%s', but declare again at '%s'.",
|
||||
"",
|
||||
{ "Make sure the resource names of same type are unique." },
|
||||
{ "Make sure the resource name of the same type is unique." },
|
||||
{} } },
|
||||
{ ERR_CODE_RESOURCE_ID_EXCEED,
|
||||
{ ERR_CODE_RESOURCE_ID_EXCEED,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The resource id %lu exceed, greater than the max id %lu",
|
||||
"The resource id '%lu' exceed, greater than the max id '%lu'.",
|
||||
"",
|
||||
{},
|
||||
{ "Delete useless resources and recompile.", "Specify a smaller start id." },
|
||||
{} } },
|
||||
{ ERR_CODE_RESOURCE_ID_NOT_DEFINED,
|
||||
{ ERR_CODE_RESOURCE_ID_NOT_DEFINED,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The resource id not be defined, resource type: %s, name: '%s'.",
|
||||
"The id of resource '%s' of the '%s' type is not defined.",
|
||||
"",
|
||||
{},
|
||||
{ "Delete useless resources and recompile." },
|
||||
{} } },
|
||||
{ ERR_CODE_REF_NOT_DEFINED,
|
||||
{ ERR_CODE_REF_NOT_DEFINED,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"The resource reference '%s' don't be defined.",
|
||||
"The resource reference '%s' is not defined.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ARRAY_DECOMPOSE_ERROR,
|
||||
{ ERR_CODE_ARRAY_DECOMPOSE_ERROR,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Decompose strings failed, name: '%s', data: '%s'.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_ARRAY_COMPOSE_ERROR,
|
||||
{ ERR_CODE_ARRAY_COMPOSE_ERROR,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Compose strings failed, name: '%s', content size: '%lu'.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_FA_ENTRY_NO_ICON_LABEL,
|
||||
{ ERR_CODE_FA_ENTRY_NO_ICON_LABEL,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Entry MainAbility must have 'icon' and 'label'.",
|
||||
"",
|
||||
{},
|
||||
{ "Check whether this resource is defined anywhere." },
|
||||
{} } },
|
||||
{ ERR_CODE_INVALID_RESOURCE_INDEX,
|
||||
{ ERR_CODE_INVALID_RESOURCE_INDEX, ERR_TYPE_RESOURCE_PACK, "Invalid resources.index %s.", "", {}, {} } },
|
||||
{ ERR_CODE_RESOURCE_INDEX_ID_NOT_FOUND,
|
||||
{ ERR_CODE_RESOURCE_INDEX_ID_NOT_FOUND,
|
||||
{ ERR_CODE_INVALID_RESOURCE_INDEX,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Find resource items in resources.index failed, the id %lu not found.",
|
||||
"Failed to parse the resources.index file, %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_RESOURCE_INDEX_ITEM_EMPTY,
|
||||
{ ERR_CODE_RESOURCE_INDEX_ITEM_EMPTY,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Find resource items in resources.index failed, the items of id %lu is empty.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_RESOURCE_INDEX_INVALID_RESTYPE,
|
||||
{ ERR_CODE_RESOURCE_INDEX_INVALID_RESTYPE,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Find resource items in resources.index failed, invalid restype '%s', expected type '%s'.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_SAVE_INDEX_ERROR,
|
||||
{ ERR_CODE_SAVE_INDEX_ERROR,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Save resources to resources.index failed, %s.",
|
||||
"",
|
||||
{},
|
||||
{} } },
|
||||
{ ERR_CODE_CREATE_ID_DEFINED_ERROR,
|
||||
{ ERR_CODE_CREATE_ID_DEFINED_ERROR,
|
||||
ERR_TYPE_RESOURCE_PACK,
|
||||
"Create id defined json '%s' failed, %s.",
|
||||
"",
|
||||
{},
|
||||
{ "Verify that the format of the resource.index file is correct." },
|
||||
{} } },
|
||||
|
||||
// 11212xxx
|
||||
{ ERR_CODE_PARSE_HAP_ERROR,
|
||||
{ ERR_CODE_PARSE_HAP_ERROR, ERR_TYPE_RESOURCE_PACK, "Parse hap failed, %s.", "", {}, {} } },
|
||||
{ ERR_CODE_PARSE_HAP_ERROR, ERR_TYPE_RESOURCE_DUMP, "Failed to parse the hap, %s.", "", {}, {} } },
|
||||
};
|
||||
|
||||
ErrorInfo GetError(const uint32_t &errCode)
|
||||
|
||||
@@ -119,10 +119,12 @@ bool TranslatableParse::CheckBaseStringPriority(const cJSON *attrNode, const std
|
||||
}
|
||||
string priorityValue = priorityNode->valuestring;
|
||||
if (find(PRIORITY_ATTRS.begin(), PRIORITY_ATTRS.end(), priorityValue) == PRIORITY_ATTRS.end()) {
|
||||
string message("");
|
||||
string message("[");
|
||||
for (const auto &value : PRIORITY_ATTRS) {
|
||||
message.append("'" + value + "' ");
|
||||
message.append("\"" + value + "\",");
|
||||
}
|
||||
message.pop_back();
|
||||
message.append("]");
|
||||
PrintError(GetError(ERR_CODE_INVALID_TRANSLATE_PRIORITY)
|
||||
.FormatCause(priorityValue.c_str(), message.c_str())
|
||||
.SetPosition(filePath));
|
||||
|
||||
Reference in New Issue
Block a user