|
tesseract 3.04.01
|
#include <fileio.h>
Public Member Functions | |
| InputBuffer (FILE *stream) | |
| InputBuffer (FILE *stream, size_t size) | |
| ~InputBuffer () | |
| bool | Read (string *out) |
| bool | CloseFile () |
| tesseract::InputBuffer::InputBuffer | ( | FILE * | stream | ) | [explicit] |
Definition at line 135 of file fileio.cpp.
: stream_(stream) {
fseek(stream_, 0, SEEK_END);
filesize_ = ftell(stream_);
fseek(stream_, 0, SEEK_SET);
}
| tesseract::InputBuffer::InputBuffer | ( | FILE * | stream, |
| size_t | size | ||
| ) |
Definition at line 142 of file fileio.cpp.
: stream_(stream) {
fseek(stream_, 0, SEEK_END);
filesize_ = ftell(stream_);
fseek(stream_, 0, SEEK_SET);
}
| tesseract::InputBuffer::~InputBuffer | ( | ) |
Definition at line 149 of file fileio.cpp.
{
if (stream_ != NULL) {
fclose(stream_);
}
}
| bool tesseract::InputBuffer::CloseFile | ( | ) |
Definition at line 169 of file fileio.cpp.
{
int ret = fclose(stream_);
stream_ = NULL;
return ret == 0;
}
| bool tesseract::InputBuffer::Read | ( | string * | out | ) |
Definition at line 155 of file fileio.cpp.
{
char buf[BUFSIZ + 1];
int l;
while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
if (ferror(stream_)) {
clearerr(stream_);
return false;
}
buf[l] = 0;
out->append(buf);
}
return true;
}