|
tesseract
3.03
|
#include <fileio.h>
Public Member Functions | |
| InputBuffer (FILE *stream) | |
| InputBuffer (FILE *stream, size_t size) | |
| ~InputBuffer () | |
| bool | ReadLine (string *out) |
| bool | CloseFile () |
| tesseract::InputBuffer::InputBuffer | ( | FILE * | stream | ) | [explicit] |
Definition at line 138 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 145 of file fileio.cpp.
: stream_(stream) {
fseek(stream_, 0, SEEK_END);
filesize_ = ftell(stream_);
fseek(stream_, 0, SEEK_SET);
}
Definition at line 152 of file fileio.cpp.
{
if (stream_ != NULL) {
fclose(stream_);
}
}
| bool tesseract::InputBuffer::CloseFile | ( | ) |
Definition at line 187 of file fileio.cpp.
{
int ret = fclose(stream_);
stream_ = NULL;
return ret == 0;
}
| bool tesseract::InputBuffer::ReadLine | ( | string * | out | ) |
Definition at line 158 of file fileio.cpp.
{
ASSERT_HOST(stream_ != NULL);
char* line = NULL;
int len = -1;
#ifdef _WIN32
char line_buf[BUFSIZ];
if ((line = fgets(line_buf, BUFSIZ, stream_)) != NULL) {
len = strlen(line);
if (line_buf[0] != '\0' && line_buf[len - 1] == '\n')
line_buf[len - 1] = '\0';
} else {
return false;
}
*out = string(line);
#else
size_t line_size;
len = getline(&line, &line_size, stream_);
if (len < 0) {
return false;
}
if (len >= 1 && line[len - 1] == '\n')
line[len - 1] = '\0';
*out = string(line);
free(line);
#endif // _WIN32
return true;
}