Skip to content
Snippets Groups Projects
Commit f06be701 authored by Lars Bilke's avatar Lars Bilke
Browse files

Merge branch 'GocadTSurfaceReader_Linux' into 'master'

[A/IO/GocadIO] Gocadreader - Fix reading line if Gocad file is represented as CR+LF.

See merge request ogs/ogs!3460
parents 2b51b1b3 902b1c0c
No related branches found
No related tags found
No related merge requests found
......@@ -118,6 +118,26 @@ DataType datasetFound(std::ifstream& in)
}
return DataType::UNDEFINED;
}
/// Checks if current line is a designated keyword for a GoCAD data set
void checkLineEndings(std::string const& file_name)
{
#ifndef _WIN32
std::ifstream in(file_name);
if (in.is_open())
{
std::string line;
std::getline(in, line);
if (line.back() == '\r')
{
OGS_FATAL(
"Error in input file: {:s}. The line endings are in windows "
"format. To read this file under UNIX, transform the input "
"file to unix style line endings (e.g. dos2unix).",
file_name);
}
}
#endif _WIN32
}
/// Parses the HEADER section (everything except the name is ignored right now)
bool parseHeader(std::ifstream& in, std::string& mesh_name)
......@@ -611,6 +631,8 @@ bool readFile(std::string const& file_name,
return false;
}
checkLineEndings(file_name);
DataType type;
while ((type = datasetFound(in)) != DataType::UNDEFINED)
{
......
......@@ -53,8 +53,10 @@ int main(int argc, char* argv[])
cmd.add(output_arg);
TCLAP::ValueArg<std::string> input_arg(
"i", "input-file", "Gocad triangular surfaces file (*.ts)", true, "",
"filename.ts");
"i", "input-file",
"Gocad triangular surfaces file (*.ts). Provide a file with unix file "
"endings under unix. Use dos2unix to convert. ",
true, "", "filename.ts");
cmd.add(input_arg);
cmd.parse(argc, argv);
......
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