• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __FILEINPUTSTREAM_H__
2 #define __FILEINPUTSTREAM_H__
3 
4 #include <fstream>
5 #include "InputStream.h"
6 
7 class FileInputStream : public InputStream {
8  public:
Open(const char * fileName)9   bool Open (const char* fileName) {
10     file_.open (fileName, std::ios_base::in | std::ios_base::binary);
11     return file_.is_open();
12   }
read(void * ptr,size_t len)13   int read (void* ptr, size_t len) {
14     if (!file_.good()) {
15       return -1;
16     }
17     file_.read (static_cast<char*> (ptr), len);
18     return (int) file_.gcount();
19   }
20  private:
21   std::ifstream file_;
22 };
23 
24 #endif //__FILEINPUTSTREAM_H__
25