Skip to content

Commit

Permalink
Fix NVHPC Toml11 open mode
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed May 23, 2022
1 parent 5105af1 commit ee8bdf1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/IO/JSON/JSONIOHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,19 +1320,23 @@ JSONIOHandlerImpl::getFilehandle(File fileName, Access access)
*/
std::ios_base::openmode openmode =
std::ios_base::out | std::ios_base::trunc;
#if !__NVCOMPILER
if (m_fileFormat == FileFormat::Toml)
{
openmode |= std::ios_base::binary;
}
#endif
fs->open(path, openmode);
break;
}
case Access::READ_ONLY: {
std::ios_base::openmode openmode = std::ios_base::in;
#if !__NVCOMPILER
if (m_fileFormat == FileFormat::Toml)
{
openmode |= std::ios_base::binary;
}
#endif
fs->open(path, openmode);
break;
}
Expand Down
18 changes: 14 additions & 4 deletions src/auxiliary/JSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ namespace
}
else
{
std::istringstream istream(
options.c_str(), std::ios_base::binary | std::ios_base::in);
std::istringstream istream(options.c_str(), std::ios_base::in);
toml::value tomlVal =
toml::parse(istream, "[inline TOML specification]");
res.config = json::tomlToJson(tomlVal);
Expand All @@ -315,7 +314,13 @@ ParsedConfig parseOptions(std::string const &options, bool considerFiles)
{
std::fstream handle;
handle.open(
filename.value(), std::ios_base::binary | std::ios_base::in);
filename.value(),
#if __NVCOMPILER
std::ios_base::in
#else
std::ios_base::binary | std::ios_base::in
#endif
);
ParsedConfig res;
if (auxiliary::ends_with(filename.value(), ".toml"))
{
Expand Down Expand Up @@ -358,7 +363,12 @@ parseOptions(std::string const &options, MPI_Comm comm, bool considerFiles)
{
std::istringstream istream(
fileContent.c_str(),
std::ios_base::binary | std::ios_base::in);
#if __NVCOMPILER
std::ios_base::in
#else
std::ios_base::binary | std::ios_base::in
#endif
);
res.config = tomlToJson(toml::parse(istream, filename.value()));
res.originallySpecifiedAs = SupportedLanguages::TOML;
}
Expand Down

0 comments on commit ee8bdf1

Please sign in to comment.