33#include "../mxlib.hpp"
51 const std::string &fileName
56 fout = fopen( fileName.c_str(),
"rb" );
62 int nrd = fread( data,
sizeof( T ), szData, fout );
76 "Error reading from file, did not read all elements. [" + fileName +
"]" ) );
80 int res = fclose( fout );
107 fout = fopen( fileName.c_str(),
"wb" );
113 int nwr = fwrite( data,
sizeof( T ), szData, fout );
128 "Error writing to file, did not write all elements. [" + fileName +
"]" ));
132 int res = fclose( fout );
Augments an exception with the source file and line.
static constexpr error_t errno2error_t(const int &err)
Convert an errno code to error_t.
@ filererr
An error occurred while reading from a file.
@ filecerr
An error occurred while closing a file.
@ filewerr
An error occurred while writing to a file.
int writeRawBinary(const std::string &fileName, T *data, size_t szData)
Write an array of data to file as raw binary.
int readRawBinary(T *data, size_t szData, const std::string &fileName)
Read an array of data from a file as raw binary.