Skip to content

Commit

Permalink
Open stdin as binary on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alesimula committed Oct 29, 2021
1 parent dc36ab4 commit f250daf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
#include <boost/property_tree/xml_parser.hpp>
#include <boost/program_options.hpp>

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define PLATFORM_WINDOWS
#include <io.h>
#include <fcntl.h>
#endif

#include <unzip.h>

namespace boost_pt = boost::property_tree;
Expand Down Expand Up @@ -125,6 +131,12 @@ void process_file(const std::string& input_filename,
if (!input_filename.empty()) {
input_file_stream.open(input_filename, std::ios::binary);
}
else {
//TODO Linux?
#ifdef PLATFORM_WINDOWS
_setmode(_fileno(stdin), _O_BINARY);
#endif
}
std::istream& ifs = !input_filename.empty()
? input_file_stream
: std::cin;
Expand Down

0 comments on commit f250daf

Please sign in to comment.