Skip to content

Instantly share code, notes, and snippets.

@bhouston
Created June 30, 2014 12:37
Show Gist options
  • Save bhouston/26bd9f6db56a1ab42a2d to your computer and use it in GitHub Desktop.
Save bhouston/26bd9f6db56a1ab42a2d to your computer and use it in GitHub Desktop.
class OStream::PrivateData
{
private:
char filestreamBuffer[STREAM_BUF_SIZE];
public:
PrivateData(const std::string & iFileName) :
stream(NULL), fileName(iFileName), startPos(0)
{
std::ofstream * filestream = new std::ofstream(fileName.c_str(),
std::ios_base::trunc | std::ios_base::binary);
if (filestream->is_open())
{
stream = filestream;
stream->rdbuf()->pubsetbuf( filestreamBuffer, STREAM_BUF_SIZE );
stream->exceptions ( std::ofstream::failbit |
std::ofstream::badbit );
}
else
{
filestream->close();
delete filestream;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment