Rework check for readable input file

This reverts commit 1a096441d0 and
implements an alternate check which allows input from stdin.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-10-06 22:00:15 +02:00
parent 140bfa43f0
commit 67bf9062df
2 changed files with 9 additions and 7 deletions

View File

@ -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

View File

@ -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) {