From 52f0bd2ea177d1e87c4a318e95a620a9867488e4 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Thu, 22 Sep 2016 14:34:01 +0000 Subject: [PATCH] #1109 Work in Progress on MinGW/32. Put stdout into binary mode for options -pC -pX, -eABC-, -eABC- --- include/exiv2/image.hpp | 1 + src/actions.cpp | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp index 09c8dcb9..6eee4ff1 100644 --- a/include/exiv2/image.hpp +++ b/include/exiv2/image.hpp @@ -105,6 +105,7 @@ namespace Exiv2 { @throw Error if reading of the file fails or the image data is not valid (does not look like data of the specific image type). @caution This function is not thread safe and intended for exiv2 -pS for debugging. + @caution You may need to put the stream into binary mode (see src/actions.cpp) */ virtual void printStructure(std::ostream& out, PrintStructureOption option =kpsNone, int depth=0); /*! diff --git a/src/actions.cpp b/src/actions.cpp index 873f6b0a..0e74e5cf 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -234,15 +234,24 @@ namespace Action { try { path_ = path; int rc = 0; + Exiv2::PrintStructureOption option = Exiv2::kpsNone ; switch (Params::instance().printMode_) { - case Params::pmSummary: rc = printSummary(); break; - case Params::pmList: rc = printList(); break; - case Params::pmComment: rc = printComment(); break; - case Params::pmPreview: rc = printPreviewList(); break; - case Params::pmStructure: rc = printStructure(std::cout,Exiv2::kpsBasic) ; break; - case Params::pmXMP: rc = printStructure(std::cout,Exiv2::kpsXMP) ; break; - case Params::pmIccProfile:rc = printStructure(std::cout,Exiv2::kpsIccProfile); break; - case Params::pmRecursive: rc = printStructure(std::cout,Exiv2::kpsRecursive) ; break; + case Params::pmSummary: rc = printSummary(); break; + case Params::pmList: rc = printList(); break; + case Params::pmComment: rc = printComment(); break; + case Params::pmPreview: rc = printPreviewList(); break; + case Params::pmStructure: rc = printStructure(std::cout,Exiv2::kpsBasic) ; break; + case Params::pmRecursive: rc = printStructure(std::cout,Exiv2::kpsRecursive) ; break; + + case Params::pmXMP: + option = option == Exiv2::kpsNone ? Exiv2::kpsXMP : option; // drop + case Params::pmIccProfile:{ + option = option == Exiv2::kpsNone ? Exiv2::kpsIccProfile : option; +#ifdef __MINGW__ + _setmode(_fileno(stdout),O_BINARY); +#endif + rc = printStructure(std::cout,option); + } break; } return rc; } @@ -1060,6 +1069,12 @@ namespace Action { path_ = path; int rc = 0; +#ifdef __MINGW__ + if ( Params::instance().target_ & Params::ctStdInOut ) { + _setmode(_fileno(stdout),O_BINARY); + } +#endif + if (!rc && Params::instance().target_ & Params::ctThumb) { rc = writeThumbnail(); } @@ -1249,6 +1264,13 @@ namespace Action { << ": " << _("Failed to open the file\n"); return -1; } + +#ifdef __MINGW__ + if ( Params::instance().target_ & Params::ctStdInOut ) { + _setmode(_fileno(stdin),O_BINARY); + } +#endif + int rc = 0; Timestamp ts; if (Params::instance().preserve_) {