Skip to content
Snippets Groups Projects
Commit b0157a7f authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[BL] FileTools; Add createBinaryFile with check.

parent 403caa7c
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
*/
#include "FileTools.h"
#include "Error.h"
#include "StringTools.h"
#include <sys/stat.h>
......@@ -56,6 +57,16 @@ void truncateFile( std::string const& filename)
ofs.close();
}
std::ofstream createBinaryFile(std::string const& file_name)
{
std::ofstream os(file_name, std::ios::binary);
if (!os)
{
OGS_FATAL("Could not open file '%s' for output.", file_name.c_str());
}
return os;
}
namespace
{
......
......@@ -97,6 +97,13 @@ std::vector<T> readBinaryArray(std::string const& filename, std::size_t const n)
return std::vector<T>();
}
/**
* Create a binary file for output.
*
* Wrapper around the std::ofstream constructor with error checking.
*/
std::ofstream createBinaryFile(std::string const& file_name);
/**
* \brief truncate a file
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment