/***************************************************************************1Copyright (C) 2007 by Nach2http://nsrt.edgeemu.com34Copyright (C) 2007-2011 by Sindre Aamås5[email protected]67This program is free software; you can redistribute it and/or modify8it under the terms of the GNU General Public License version 2 as9published by the Free Software Foundation.1011This program is distributed in the hope that it will be useful,12but WITHOUT ANY WARRANTY; without even the implied warranty of13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14GNU General Public License version 2 for more details.1516You should have received a copy of the GNU General Public License17version 2 along with this program; if not, write to the18Free Software Foundation, Inc.,1959 Temple Place - Suite 330, Boston, MA 02111-1307, USA.20***************************************************************************/21#ifndef GAMBATTE_STD_FILE_H22#define GAMBATTE_STD_FILE_H2324#include "file.h"25#include <fstream>2627namespace gambatte {2829class StdFile : public File {30std::ifstream stream;31std::size_t fsize;3233public:34explicit StdFile(const char *filename)35: stream(filename, std::ios::in | std::ios::binary), fsize(0)36{37if (stream) {38stream.seekg(0, std::ios::end);39fsize = stream.tellg();40stream.seekg(0, std::ios::beg);41}42}4344virtual void rewind() { stream.seekg(0, std::ios::beg); }45virtual std::size_t size() const { return fsize; };46virtual void read(char *buffer, std::size_t amount) { stream.read(buffer, amount); }47virtual bool fail() const { return stream.fail(); }48};4950}5152#endif535455