Always write and read wrap files in binary mode to prevent writing CRLF line endings on windows (messes up expected unit test files)
parent
e9f710a1ac
commit
10c5ebae73
|
@ -35,7 +35,7 @@ void FileWriter::emit(bool add_header, bool force_overwrite) const {
|
|||
// Only write a file if it is new, an update, or overwrite is forced
|
||||
string new_contents = oss.str();
|
||||
if (force_overwrite || !file_exists || existing_contents != new_contents) {
|
||||
ofstream ofs(filename_.c_str());
|
||||
ofstream ofs(filename_.c_str(), ios::binary); // Binary to use LF line endings instead of CRLF
|
||||
if (!ofs) throw CantOpenFile(filename_);
|
||||
|
||||
// header
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace std;
|
|||
|
||||
/* ************************************************************************* */
|
||||
string file_contents(const string& filename, bool skipheader) {
|
||||
ifstream ifs(filename.c_str());
|
||||
ifstream ifs(filename.c_str(), ios::binary); // Do not do LF/CRLF translation - we always write in binary mode too
|
||||
if(!ifs) throw CantOpenFile(filename);
|
||||
|
||||
// read file into stringstream
|
||||
|
|
Loading…
Reference in New Issue