Update ccutil.cpp (#3768)

Fixes #3767.

Co-authored-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
CSBVision 2022-03-11 15:31:27 +01:00 committed by GitHub
parent 9f278588eb
commit e9b3939566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,21 +63,24 @@ void CCUtil::main_setup(const std::string &argv0, const std::string &basename) {
char *separator = std::strrchr(path, '\\');
if (separator != nullptr) {
*separator = '\0';
datadir = path;
datadir += "/tessdata";
std::string subdir = path;
subdir += "/tessdata";
if (_access(subdir.c_str(), 0) == 0) {
datadir = subdir;
}
}
}
#endif /* _WIN32 */
#if defined(TESSDATA_PREFIX)
} else {
// Use tessdata prefix which was compiled in.
datadir = TESSDATA_PREFIX "/tessdata";
#endif
}
// datadir may still be empty:
if (datadir.empty()) {
#if defined(TESSDATA_PREFIX)
// Use tessdata prefix which was compiled in.
datadir = TESSDATA_PREFIX "/tessdata";
#else
datadir = "./";
#endif /* TESSDATA_PREFIX */
}
// check for missing directory separator