Skip to content

Commit

Permalink
open ifstream in zstr as binary always if windows
Browse files Browse the repository at this point in the history
- fixes reading compressed input on windows by avoiding trouble with
  end-of-line conversions, see zstr/issues#15
- the lp+mps readers can handle \r in lines, fortunately
  • Loading branch information
svigerske committed Apr 6, 2022
1 parent a9a3f4a commit c78f01d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions extern/zstr/zstr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ class ifstream
{
public:
explicit ifstream(const std::string filename, std::ios_base::openmode mode = std::ios_base::in, size_t buff_size = default_buff_size)
: detail::strict_fstream_holder< strict_fstream::ifstream >(filename, mode),
: detail::strict_fstream_holder< strict_fstream::ifstream >(filename, mode
#ifdef _WIN32 // to avoid problems with conversion of \r\n, only windows as otherwise there are problems on mac
| std::ios_base::binary
#endif
),
std::istream(new istreambuf(_fs.rdbuf(), buff_size))
{
exceptions(std::ios_base::badbit);
Expand All @@ -424,7 +428,11 @@ class ifstream
_fs.close();
}
void open(const std::string filename, std::ios_base::openmode mode = std::ios_base::in) {
_fs.open(filename, mode);
_fs.open(filename, mode
#ifdef _WIN32 // to avoid problems with conversion of \r\n, only windows as otherwise there are problems on mac
| std::ios_base::binary
#endif
);
std::istream::operator=(std::istream(new istreambuf(_fs.rdbuf())));
}
bool is_open() const {
Expand Down

0 comments on commit c78f01d

Please sign in to comment.