OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
benchmark_app/cpp: report an error if no files were found. (#26663)
Vladimir Zlobin44b86a860ecb
diff --git a/samples/cpp/common/utils/src/args_helper.cpp b/samples/cpp/common/utils/src/args_helper.cppindex f4a3d10ceb0..ba58f98e498 100644--- a/samples/cpp/common/utils/src/args_helper.cpp+++ b/samples/cpp/common/utils/src/args_helper.cpp@@ -29,8 +29,7 @@void readInputFilesArguments(std::vector<std::string>& files, const std::string& arg) {struct stat sb;if (stat(arg.c_str(), &sb) != 0) {- slog::warn << "File " << arg << " cannot be opened!" << slog::endl;- return;+ throw std::invalid_argument(arg + " file or directory not found.");}if (S_ISDIR(sb.st_mode)) {struct CloseDir {@@ -43,17 +42,20 @@ void readInputFilesArguments(std::vector<std::string>& files, const std::string&using Dir = std::unique_ptr<DIR, CloseDir>;Dir dp(opendir(arg.c_str()));if (dp == nullptr) {- slog::warn << "Directory " << arg << " cannot be opened!" << slog::endl;- return;+ throw std::invalid_argument(arg + " directory cannot be opened!");}struct dirent* ep;+ size_t files_size = files.size();while (nullptr != (ep = readdir(dp.get()))) {std::string fileName = ep->d_name;if (fileName == "." || fileName == "..")continue;files.push_back(arg + "/" + ep->d_name);}+ if (files.size() == files_size) {+ throw std::invalid_argument("No files were found in directory " + arg);+ }} else {files.push_back(arg);}