From 78db117e9cc6aa09cc7d4d43ea8f9bc68feef306 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 16 Jul 2014 13:00:59 -0400 Subject: [PATCH] windows standard io fix for binary data --- openbr/plugins/gallery.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+), 0 deletions(-) diff --git a/openbr/plugins/gallery.cpp b/openbr/plugins/gallery.cpp index 243fa1d..0864d46 100644 --- a/openbr/plugins/gallery.cpp +++ b/openbr/plugins/gallery.cpp @@ -39,6 +39,11 @@ #include "MatlabIOContainer.hpp" #endif +#ifdef _WIN32 +#include +#include +#endif // _WIN32 + namespace br { @@ -96,11 +101,27 @@ class BinaryGallery : public Gallery void init() { const QString baseName = file.baseName(); + if (baseName == "stdin") { +#ifdef _WIN32 + if(_setmode(_fileno(stdin), _O_BINARY) == -1) + qFatal("Failed to set stdin to binary mode!"); +#endif // _WIN32 + gallery.open(stdin, QFile::ReadOnly); } else if (baseName == "stdout") { +#ifdef _WIN32 + if(_setmode(_fileno(stdout), _O_BINARY) == -1) + qFatal("Failed to set stdout to binary mode!"); +#endif // _WIN32 + gallery.open(stdout, QFile::WriteOnly); } else if (baseName == "stderr") { +#ifdef _WIN32 + if(_setmode(_fileno(stderr), _O_BINARY) == -1) + qFatal("Failed to set stderr to binary mode!"); +#endif // _WIN32 + gallery.open(stderr, QFile::WriteOnly); } else { gallery.setFileName(file); -- libgit2 0.21.4