mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-04 01:39:16 +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)),
|
buf.assign((std::istreambuf_iterator<char>(std::cin)),
|
||||||
(std::istreambuf_iterator<char>()));
|
(std::istreambuf_iterator<char>()));
|
||||||
data = reinterpret_cast<const l_uint8 *>(buf.data());
|
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
|
// Here is our autodetection
|
||||||
|
@ -534,13 +534,6 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_SUCCESS;
|
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);
|
FixPageSegMode(&api, pagesegmode);
|
||||||
|
|
||||||
if (dpi) {
|
if (dpi) {
|
||||||
|
Loading…
Reference in New Issue
Block a user