Skip to content

Commit

Permalink
Check if datadir exists: fixes tesseract-ocr#4364
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Dec 2, 2024
1 parent 2e5a114 commit b95fd2e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ static void ExtractFontName(const char* filename, std::string* fontname) {
*/
static void addAvailableLanguages(const std::string &datadir,
std::vector<std::string> *langs) {
if (!std::filesystem::exists(datadir)) {
std::cerr << "Error: The directory '" << datadir << "' does not exist.\n";
return;
}
for (const auto& entry :
std::filesystem::recursive_directory_iterator(datadir,
std::filesystem::directory_options::follow_directory_symlink |
Expand Down

0 comments on commit b95fd2e

Please sign in to comment.