mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-03 09:24:24 +08:00
Merge pull request #1960 from stweil/errhandling
Rework check for readable input file
This commit is contained in:
commit
5cf5c80ba1
@ -1130,6 +1130,15 @@ bool TessBaseAPI::ProcessPagesInternal(const char* filename,
|
||||
buf.assign((std::istreambuf_iterator<char>(std::cin)),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
data = reinterpret_cast<const l_uint8 *>(buf.data());
|
||||
} else {
|
||||
// Check whether the input file can be read.
|
||||
if (FILE* file = fopen(filename, "rb")) {
|
||||
fclose(file);
|
||||
} else {
|
||||
fprintf(stderr, "Error, cannot read input file %s: %s\n",
|
||||
filename, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Here is our autodetection
|
||||
|
@ -534,13 +534,6 @@ int main(int argc, char** argv) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (FILE* file = fopen(image, "r")) {
|
||||
fclose(file);
|
||||
} else {
|
||||
fprintf(stderr, "Cannot open input file: %s\n", image);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
FixPageSegMode(&api, pagesegmode);
|
||||
|
||||
if (dpi) {
|
||||
|
Loading…
Reference in New Issue
Block a user