Skip to content

Commit

Permalink
fix portability of text file parsing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Mar 14, 2020
1 parent e98e6b6 commit 66957f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/sample_text_file.txt eol=lf

5 changes: 4 additions & 1 deletion libs/io/src/vector_loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <mrpt/io/CFileOutputStream.h>
#include <mrpt/io/vector_loadsave.h>


using namespace mrpt;
using namespace mrpt::io;
using namespace std;
Expand Down Expand Up @@ -70,7 +71,9 @@ bool mrpt::io::loadTextFile(
std::string mrpt::io::file_get_contents(const std::string& fileName)
{
// Credits: https://stackoverflow.com/a/2602258/1631514
std::ifstream t(fileName);
// Note: Add "binary" to make sure the "tellg" file size matches the actual
// number of read bytes afterwards:
std::ifstream t(fileName, ios::binary);
if (!t.is_open())
THROW_EXCEPTION_FMT(
"file_get_contents(): Error opening for read file `%s`",
Expand Down

0 comments on commit 66957f7

Please sign in to comment.