mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-08 09:37:53 +00:00
33 lines
647 B
C++
33 lines
647 B
C++
#ifndef MANGLE_STREAM_FILESERVER_H
|
|
#define MANGLE_STREAM_FILESERVER_H
|
|
|
|
#include "std_stream.hpp"
|
|
#include <fstream>
|
|
#include <stdexcept>
|
|
|
|
namespace Mangle {
|
|
namespace Stream {
|
|
|
|
/** Very simple file input stream, based on std::ifstream
|
|
*/
|
|
class FileStream : public StdStream
|
|
{
|
|
std::ifstream file;
|
|
|
|
public:
|
|
FileStream(const std::string &name)
|
|
: StdStream(&file)
|
|
{
|
|
file.open(name.c_str(), std::ios::binary);
|
|
|
|
if(file.fail())
|
|
throw std::runtime_error("FileStream: failed to open file " + name);
|
|
}
|
|
~FileStream() { file.close(); }
|
|
};
|
|
|
|
typedef boost::shared_ptr<FileStream> FileStreamPtr;
|
|
|
|
}} // namespaces
|
|
#endif
|