2014-01-18 12:31:54 +01:00
|
|
|
#ifndef __FILEINPUTSTREAM_H__
|
|
|
|
#define __FILEINPUTSTREAM_H__
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include "InputStream.h"
|
|
|
|
|
|
|
|
class FileInputStream : public InputStream {
|
|
|
|
public:
|
2014-06-26 03:50:41 +02:00
|
|
|
bool Open (const char* fileName) {
|
|
|
|
file_.open (fileName, std::ios_base::in | std::ios_base::binary);
|
2014-01-18 12:31:54 +01:00
|
|
|
return file_.is_open();
|
|
|
|
}
|
2014-06-26 03:50:41 +02:00
|
|
|
int read (void* ptr, size_t len) {
|
2014-02-05 11:04:32 +01:00
|
|
|
if (!file_.good()) {
|
|
|
|
return -1;
|
|
|
|
}
|
2014-06-26 03:50:41 +02:00
|
|
|
file_.read (static_cast<char*> (ptr), len);
|
2015-01-16 09:39:55 +01:00
|
|
|
return (int) file_.gcount();
|
2014-01-18 12:31:54 +01:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
std::ifstream file_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__FILEINPUTSTREAM_H__
|