mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 13:56:38 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			647 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			32 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
 |