"Fossies" - the Fresh Open Source Software Archive

Member "tesseract-ocr/doc/html/input__file__buffer_8cpp_source.html" (26 Oct 2012, 13741 Bytes) of package /linux/misc/old/tesseract-ocr-3.02.02-doc-html.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the tesseract-ocr-3.02.02-doc-html.tar.gz project site itself.

Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
input_file_buffer.cpp
Go to the documentation of this file.
1 // Copyright 2008 Google Inc.
2 // All Rights Reserved.
3 // Author: ahmadab@google.com (Ahmad Abdulkader)
4 //
5 // input_file_buffer.h: Declarations of a class for an object that
6 // represents an input file buffer.
7 
8 #include <string>
9 #include "input_file_buffer.h"
10 
11 namespace tesseract {
12 // default and only contsructor
13 InputFileBuffer::InputFileBuffer(const string &file_name)
14  : file_name_(file_name) {
15  fp_ = NULL;
16 }
17 
18 // virtual destructor
20  if (fp_ != NULL) {
21  fclose(fp_);
22  }
23 }
24 
25 // Read the specified number of bytes to the specified input buffer
26 int InputFileBuffer::Read(void *buffer, int bytes_to_read) {
27  // open the file if necessary
28  if (fp_ == NULL) {
29  fp_ = fopen(file_name_.c_str(), "rb");
30  if (fp_ == NULL) {
31  return 0;
32  }
33  }
34  return fread(buffer, 1, bytes_to_read, fp_);
35 }
36 }