From 44f15565ac141016a20040e1374cdd289bf0ce30 Mon Sep 17 00:00:00 2001 From: liduo Date: Thu, 24 Apr 2025 15:07:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3warning=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liduo --- src/cmd/package_parser.cpp | 4 ++-- src/compression_parser.cpp | 48 +++++++++++++++++++------------------- src/config_parser.cpp | 4 ++-- src/file_entry.cpp | 2 +- src/id_defined_parser.cpp | 4 ++-- src/resconfig_parser.cpp | 2 +- src/resource_append.cpp | 2 +- src/resource_module.cpp | 6 ++--- src/resource_pack.cpp | 2 +- src/resource_util.cpp | 4 ++-- src/thread_pool.cpp | 2 +- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/cmd/package_parser.cpp b/src/cmd/package_parser.cpp index 0f2ba4a..43ebc91 100644 --- a/src/cmd/package_parser.cpp +++ b/src/cmd/package_parser.cpp @@ -364,7 +364,7 @@ uint32_t PackageParser::AddAppend(const string& argValue) { string appendPath = ResourceUtil::RealPath(argValue); if (appendPath.empty()) { - cout << "Warning: invalid compress '" << argValue << "'" << endl; + cerr << "Warning: invalid compress '" << argValue << "'" << endl; appendPath = argValue; } auto ret = find_if(append_.begin(), append_.end(), [appendPath](auto iter) {return appendPath == iter;}); @@ -573,7 +573,7 @@ uint32_t PackageParser::HandleProcess(int c, const string &argValue) { auto handler = handles_.find(c); if (handler == handles_.end()) { - cout << "Warning: unsupport " << c << endl; + cerr << "Warning: unsupport " << c << endl; return RESTOOL_ERROR; } return handler->second(argValue); diff --git a/src/compression_parser.cpp b/src/compression_parser.cpp index 1379591..c6eff90 100644 --- a/src/compression_parser.cpp +++ b/src/compression_parser.cpp @@ -125,8 +125,8 @@ uint32_t CompressionParser::Init() bool CompressionParser::ParseCompression(const cJSON *compressionNode) { if (!compressionNode) { - cout << "Warning: get 'compression' node is empty, the compiled images are not transcoded."; - cout << NEW_LINE_PATH << filePath_ << endl; + cerr << "Warning: get 'compression' node is empty, the compiled images are not transcoded."; + cerr << NEW_LINE_PATH << filePath_ << endl; return true; } if (!cJSON_IsObject(compressionNode)) { @@ -135,8 +135,8 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode) } cJSON *mediaNode = cJSON_GetObjectItem(compressionNode, "media"); if (!mediaNode) { - cout << "Warning: get 'media' node is empty, the compiled images are not transcoded."; - cout << NEW_LINE_PATH << filePath_ << endl; + cerr << "Warning: get 'media' node is empty, the compiled images are not transcoded."; + cerr << NEW_LINE_PATH << filePath_ << endl; return true; } if (!cJSON_IsObject(mediaNode)) { @@ -145,8 +145,8 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode) } cJSON *enableNode = cJSON_GetObjectItem(mediaNode, "enable"); if (!enableNode) { - cout << "Warning: get 'enable' node is empty, the compiled images are not transcoded."; - cout << NEW_LINE_PATH << filePath_ << endl; + cerr << "Warning: get 'enable' node is empty, the compiled images are not transcoded."; + cerr << NEW_LINE_PATH << filePath_ << endl; return true; } if (!cJSON_IsBool(enableNode)) { @@ -160,25 +160,25 @@ bool CompressionParser::ParseCompression(const cJSON *compressionNode) bool CompressionParser::ParseContext(const cJSON *contextNode) { if (!contextNode) { - cout << "Warning: if image transcoding is supported, the 'context' node cannot be empty."; + cerr << "Warning: if image transcoding is supported, the 'context' node cannot be empty."; return false; } if (!cJSON_IsObject(contextNode)) { - cout << "Warning: 'context' must be object."; + cerr << "Warning: 'context' must be object."; return false; } cJSON *extensionPathNode = cJSON_GetObjectItem(contextNode, "extensionPath"); if (!extensionPathNode) { - cout << "Warning: if image transcoding is supported, the 'extensionPath' node cannot be empty."; + cerr << "Warning: if image transcoding is supported, the 'extensionPath' node cannot be empty."; return false; } if (!cJSON_IsString(extensionPathNode)) { - cout << "Warning: 'extensionPath' must be string."; + cerr << "Warning: 'extensionPath' must be string."; return false; } extensionPath_ = extensionPathNode->valuestring; if (extensionPath_.empty()) { - cout << "Warning: 'extensionPath' value cannot be empty."; + cerr << "Warning: 'extensionPath' value cannot be empty."; return false; } return true; @@ -249,7 +249,7 @@ string CompressionParser::ParseRules(const cJSON *rulesNode) { string res = ""; if (!rulesNode || !cJSON_IsObject(rulesNode)) { - cout << "Warning: rules is not exist or node type is wrong" << endl; + cerr << "Warning: rules is not exist or node type is wrong" << endl; return res; } for (cJSON *item = rulesNode->child; item; item = item->next) { @@ -273,7 +273,7 @@ vector CompressionParser::ParsePath(const cJSON *pathNode) return res; } if (!cJSON_IsArray(pathNode)) { - cout << "Warning: pathnode is not array." << endl; + cerr << "Warning: pathnode is not array." << endl; return res; } for (cJSON *item = pathNode->child; item; item = item->next) { @@ -337,7 +337,7 @@ bool CompressionParser::LoadImageTranscoder() bool CompressionParser::SetTranscodeOptions(const string &optionJson, const string &optionJsonExclude) { if (!handle_) { - cout << "Warning: SetTranscodeOptions handle_ is nullptr." << endl; + cerr << "Warning: SetTranscodeOptions handle_ is nullptr." << endl; return false; } #ifdef __WIN32 @@ -346,12 +346,12 @@ bool CompressionParser::SetTranscodeOptions(const string &optionJson, const stri ISetTranscodeOptions iSetTranscodeOptions = (ISetTranscodeOptions)dlsym(handle_, "SetTranscodeOptions"); #endif if (!iSetTranscodeOptions) { - cout << "Warning: Failed to get the 'SetTranscodeOptions'." << endl; + cerr << "Warning: Failed to get the 'SetTranscodeOptions'." << endl; return false; } bool ret = (*iSetTranscodeOptions)(optionJson, optionJsonExclude); if (!ret) { - cout << "Warning: SetTranscodeOptions failed." << endl; + cerr << "Warning: SetTranscodeOptions failed." << endl; return false; } return true; @@ -361,7 +361,7 @@ TranscodeError CompressionParser::TranscodeImages(const string &imagePath, const string &outputPath, TranscodeResult &result) { if (!handle_) { - cout << "Warning: TranscodeImages handle_ is nullptr." << endl; + cerr << "Warning: TranscodeImages handle_ is nullptr." << endl; return TranscodeError::LOAD_COMPRESS_FAILED; } #ifdef __WIN32 @@ -370,17 +370,17 @@ TranscodeError CompressionParser::TranscodeImages(const string &imagePath, const ITranscodeImages iTranscodeImages = (ITranscodeImages)dlsym(handle_, "Transcode"); #endif if (!iTranscodeImages) { - cout << "Warning: Failed to get the 'Transcode'." << endl; + cerr << "Warning: Failed to get the 'Transcode'." << endl; return TranscodeError::LOAD_COMPRESS_FAILED; } TranscodeError ret = (*iTranscodeImages)(imagePath, extAppend, outputPath, result); if (ret != TranscodeError::SUCCESS) { auto iter = ERRORCODEMAP.find(ret); if (iter != ERRORCODEMAP.end()) { - cout << "Warning: TranscodeImages failed, error message: " << iter->second << ", file path = " << + cerr << "Warning: TranscodeImages failed, error message: " << iter->second << ", file path = " << imagePath << endl; } else { - cout << "Warning: TranscodeImages failed" << ", file path = " << imagePath << endl; + cerr << "Warning: TranscodeImages failed" << ", file path = " << imagePath << endl; } return ret; } @@ -390,7 +390,7 @@ TranscodeError CompressionParser::TranscodeImages(const string &imagePath, const TranscodeError CompressionParser::ScaleImage(const std::string &imagePath, std::string &outputPath) { if (!handle_) { - cout << "Warning: ScaleImage handle_ is nullptr." << endl; + cerr << "Warning: ScaleImage handle_ is nullptr." << endl; return TranscodeError::LOAD_COMPRESS_FAILED; } #ifdef __WIN32 @@ -399,17 +399,17 @@ TranscodeError CompressionParser::ScaleImage(const std::string &imagePath, std:: IScaleImage iScaleImage = (IScaleImage)dlsym(handle_, "TranscodeSLR"); #endif if (!iScaleImage) { - cout << "Warning: Failed to get the 'TranscodeSLR'." << endl; + cerr << "Warning: Failed to get the 'TranscodeSLR'." << endl; return TranscodeError::LOAD_COMPRESS_FAILED; } TranscodeError ret = (*iScaleImage)(imagePath, outputPath, { 512, 512 }); if (ret != TranscodeError::SUCCESS) { auto iter = ERRORCODEMAP.find(ret); if (iter != ERRORCODEMAP.end()) { - cout << "Warning: ScaleImage failed, error message: " << iter->second << ", file path = " << imagePath + cerr << "Warning: ScaleImage failed, error message: " << iter->second << ", file path = " << imagePath << endl; } else { - cout << "Warning: ScaleImage failed" << ", file path = " << imagePath << endl; + cerr << "Warning: ScaleImage failed" << ", file path = " << imagePath << endl; } return ret; } diff --git a/src/config_parser.cpp b/src/config_parser.cpp index 9d9f060..2447cfa 100644 --- a/src/config_parser.cpp +++ b/src/config_parser.cpp @@ -135,7 +135,7 @@ bool ConfigParser::SetAppIcon(string &icon, int64_t id) { cJSON *appNode = cJSON_GetObjectItem(root_, "app"); if (!appNode || !cJSON_IsObject(appNode)) { - cout << "Warning: 'app' not object" << endl; + cerr << "Warning: 'app' not object" << endl; return false; } cJSON_AddStringToObject(appNode, "icon", icon.c_str()); @@ -147,7 +147,7 @@ bool ConfigParser::SetAppLabel(string &label, int64_t id) { cJSON *appNode = cJSON_GetObjectItem(root_, "app"); if (!appNode || !cJSON_IsObject(appNode)) { - cout << "Warning: 'app' not object" << endl; + cerr << "Warning: 'app' not object" << endl; return false; } cJSON_AddStringToObject(appNode, "label", label.c_str()); diff --git a/src/file_entry.cpp b/src/file_entry.cpp index cc25f5e..8d87036 100644 --- a/src/file_entry.cpp +++ b/src/file_entry.cpp @@ -50,7 +50,7 @@ bool FileEntry::Init() { string filePath = filePath_.GetPath(); if (!Exist(filePath)) { - cout << "Warning: file not exist: " << filePath << endl; + cerr << "Warning: file not exist: " << filePath << endl; return false; } diff --git a/src/id_defined_parser.cpp b/src/id_defined_parser.cpp index 88129e0..bf8520a 100755 --- a/src/id_defined_parser.cpp +++ b/src/id_defined_parser.cpp @@ -104,8 +104,8 @@ uint32_t IdDefinedParser::Init(const string &filePath, bool isSystem) return RESTOOL_ERROR; } if (cJSON_GetArraySize(recordNode) == 0) { - cout << "Warning: 'record' node is empty, please check the JSON file."; - cout << NEW_LINE_PATH << filePath << endl; + cerr << "Warning: 'record' node is empty, please check the JSON file."; + cerr << NEW_LINE_PATH << filePath << endl; return RESTOOL_SUCCESS; } int64_t startSysId = 0; diff --git a/src/resconfig_parser.cpp b/src/resconfig_parser.cpp index e72fa1e..73ed4d7 100644 --- a/src/resconfig_parser.cpp +++ b/src/resconfig_parser.cpp @@ -47,7 +47,7 @@ uint32_t ResConfigParser::Init(const string &filePath, HandleBack callback) for (cJSON *item = root_->child; item; item = item->next) { auto handler = fileListHandles_.find(item->string); if (handler == fileListHandles_.end()) { - cout << "Warning: unsupport " << item->string << endl; + cerr << "Warning: unsupport " << item->string << endl; continue; } if (handler->second(item) != RESTOOL_SUCCESS) { diff --git a/src/resource_append.cpp b/src/resource_append.cpp index 4ecc9b2..34eb4db 100644 --- a/src/resource_append.cpp +++ b/src/resource_append.cpp @@ -267,7 +267,7 @@ bool ResourceAppend::ScanFiles(const unique_ptr &entry, bool ResourceAppend::ScanFile(const FileInfo &fileInfo, const string &outputPath) { if (ResourceAppend::IsBaseIdDefined(fileInfo)) { - cout << "Warning: id_defined.json does not compile to generate intermediate files" << endl; + cerr << "Warning: id_defined.json does not compile to generate intermediate files" << endl; FileEntry::FilePath outPath(outputPath); return ResourceUtil::CopyFileInner(fileInfo.filePath, outPath.Append(ID_DEFINED_FILE).GetPath()); } diff --git a/src/resource_module.cpp b/src/resource_module.cpp index 89202b2..fef6ed9 100644 --- a/src/resource_module.cpp +++ b/src/resource_module.cpp @@ -101,9 +101,9 @@ uint32_t ResourceModule::MergeResourceItem(map> &a resourceItem.GetFilePath().c_str())); return RESTOOL_ERROR; } - cout << "Warning: '"<< resourceItem.GetName() <<"' conflict, first declared."; - cout << NEW_LINE_PATH << ret->GetFilePath() << endl; - cout << "but declared again." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; + cerr << "Warning: '"<< resourceItem.GetName() <<"' conflict, first declared."; + cerr << NEW_LINE_PATH << ret->GetFilePath() << endl; + cerr << "but declared again." << NEW_LINE_PATH << resourceItem.GetFilePath() << endl; } } return RESTOOL_SUCCESS; diff --git a/src/resource_pack.cpp b/src/resource_pack.cpp index 49830c3..66dfb6e 100644 --- a/src/resource_pack.cpp +++ b/src/resource_pack.cpp @@ -177,7 +177,7 @@ uint32_t ResourcePack::GenerateHeader() const string extension = FileEntry::FilePath(headerPath).GetExtension(); auto it = headerCreaters_.find(extension); if (it == headerCreaters_.end()) { - cout << "Warning: don't support header file format '" << headerPath << "'" << endl; + cerr << "Warning: don't support header file format '" << headerPath << "'" << endl; continue; } if (it->second(headerPath) != RESTOOL_SUCCESS) { diff --git a/src/resource_util.cpp b/src/resource_util.cpp index d0392e4..3e238d0 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -503,8 +503,8 @@ bool ResourceUtil::IsValidName(const string &name) void ResourceUtil::PrintWarningMsg(vector> &noBaseResource) { for (const auto &item : noBaseResource) { - cout << "Warning: the " << ResourceUtil::ResTypeToString(item.first); - cout << " of '" << item.second << "' does not have a base resource." << endl; + cerr << "Warning: the " << ResourceUtil::ResTypeToString(item.first); + cerr << " of '" << item.second << "' does not have a base resource." << endl; } } diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index c7e0de3..b9be1ad 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -36,7 +36,7 @@ ThreadPool &ThreadPool::GetInstance() uint32_t ThreadPool::Start(const size_t &threadCount) { if (!workerThreads_.empty()) { - cout << "Warning: ThreadPool is already started." << endl; + cerr << "Warning: ThreadPool is already started." << endl; return RESTOOL_SUCCESS; } size_t hardwareCount = std::thread::hardware_concurrency();