xml-copy-editor-code/src/readfile.cpp

22 lines
460 B
C++
Raw Normal View History

2007-09-07 23:17:30 +02:00
#include <sstream>
#include "readfile.h"
2007-09-08 00:25:30 +02:00
bool ReadFile::run ( std::string fname, std::string &buffer )
2007-09-07 23:17:30 +02:00
{
2007-09-08 00:25:30 +02:00
std::ifstream ifs ( fname.c_str(), std::ios::binary|std::ios::in );
if ( !ifs.is_open() )
return false;
2007-09-07 23:17:30 +02:00
2007-09-08 00:25:30 +02:00
ifs.seekg ( 0, std::ios::end );
size_t size = ifs.tellg();
ifs.seekg ( 0, std::ios::beg );
2007-09-07 23:17:30 +02:00
2007-09-08 00:25:30 +02:00
buffer.reserve ( size + 1 );
std::stringstream iss;
iss << ifs.rdbuf();
buffer = iss.str();
return true;
2007-09-07 23:17:30 +02:00
}