mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
Ignore illegal TESSDATA_PREFIX (not existing filesystem entry, issue #4277)
Don't check for a directory, because a symbolic link is also allowed. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
2991d36a8b
commit
bc490ea7ab
@ -17,7 +17,8 @@
|
||||
#include "ccutil.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring> // for std::strrchr
|
||||
#include <cstring> // for std::strrchrA
|
||||
#include <filesystem> // for std::filesystem
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
@ -48,6 +49,12 @@ void CCUtil::main_setup(const std::string &argv0, const std::string &basename) {
|
||||
|
||||
const char *tessdata_prefix = getenv("TESSDATA_PREFIX");
|
||||
|
||||
// Ignore TESSDATA_PREFIX if there is no matching filesystem entry.
|
||||
if (tessdata_prefix != nullptr && !std::filesystem::exists(tessdata_prefix)) {
|
||||
tprintf("Warning: TESSDATA_PREFIX %s does not exist, ignore it\n", tessdata_prefix);
|
||||
tessdata_prefix = nullptr;
|
||||
}
|
||||
|
||||
if (!argv0.empty()) {
|
||||
/* Use tessdata prefix from the command line. */
|
||||
datadir = argv0;
|
||||
|
Loading…
Reference in New Issue
Block a user