From 81e3ed992a31db49b392a2e287f975e0e160a1b5 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 3 Aug 2023 00:22:24 +0000 Subject: [PATCH] remove useless code UCRT has obsoleted all of this Signed-off-by: Rosen Penev --- app/actions.cpp | 14 -------------- app/exiv2.cpp | 4 ---- samples/geotag.cpp | 7 +------ src/basicio.cpp | 11 ----------- 4 files changed, 1 insertion(+), 35 deletions(-) diff --git a/app/actions.cpp b/app/actions.cpp index 7678a5dfa9..cf76cef553 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -31,20 +31,11 @@ #endif #if defined(_WIN32) -#include -#include -#include #include #else #include #endif -#ifndef _WIN32 -#define _setmode(a, b) \ - do { \ - } while (false) -#endif - #if __has_include() #include namespace fs = std::filesystem; @@ -194,7 +185,6 @@ static int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const st } } } else { - _setmode(fileno(stdout), O_BINARY); result = printStructure(std::cout, option, path); } @@ -785,9 +775,6 @@ int Extract::run(const std::string& path) { int rc = 0; bool bStdout = (Params::instance().target_ & Params::ctStdInOut) != 0; - if (bStdout) { - _setmode(fileno(stdout), _O_BINARY); - } if (Params::instance().target_ & Params::ctThumb) { rc = writeThumbnail(); @@ -1794,7 +1781,6 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType // if we used a temporary target, copy it to stdout if (rc == 0 && bStdout) { - _setmode(fileno(stdout), O_BINARY); if (auto f = std::fopen(target.c_str(), "rb")) { char buffer[8 * 1024]; size_t n = 1; diff --git a/app/exiv2.cpp b/app/exiv2.cpp index a35ead58c9..7d6b952b2e 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -23,8 +23,6 @@ #include #if defined(_WIN32) -#include -#include #include #else #include @@ -959,8 +957,6 @@ void Params::getStdin(Exiv2::DataBuf& buf) { if (stdinBuf.empty()) { #if defined(_WIN32) DWORD fdwMode; - _setmode(fileno(stdin), O_BINARY); - Sleep(300); if (!GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &fdwMode)) { // failed: stdin has bytes! #else // http://stackoverflow.com/questions/34479795/make-c-not-wait-for-user-input/34479916#34479916 diff --git a/samples/geotag.cpp b/samples/geotag.cpp index 7ad726fea4..923f4dd93c 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -20,7 +20,6 @@ namespace fs = std::experimental::filesystem; #ifdef _WIN32 #include -char* realpath(const char* file, char* path); #define lstat stat #if _MSC_VER < 1400 #define strcpy_s(d, l, s) strcpy(d, s) @@ -383,11 +382,7 @@ int timeZoneAdjust() { [[maybe_unused]] time_t now = time(nullptr); int offset; -#if defined(_WIN32) - TIME_ZONE_INFORMATION TimeZoneInfo; - GetTimeZoneInformation(&TimeZoneInfo); - offset = -(((int)TimeZoneInfo.Bias + (int)TimeZoneInfo.DaylightBias) * 60); -#elif defined(__CYGWIN__) +#if defined(__CYGWIN__) struct tm lcopy = *localtime(&now); time_t gmt = timegm(&lcopy); // timegm modifies lcopy offset = (int)(((long signed int)gmt) - ((long signed int)now)); diff --git a/src/basicio.cpp b/src/basicio.cpp index 1ff7949e28..bedcd60128 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -883,12 +883,6 @@ void XPathIo::ReadStdin() { if (isatty(fileno(stdin))) throw Error(ErrorCode::kerInputDataReadFailed); -#ifdef _O_BINARY - // convert stdin to binary - if (_setmode(_fileno(stdin), _O_BINARY) == -1) - throw Error(ErrorCode::kerInputDataReadFailed); -#endif - char readBuf[100 * 1024]; std::streamsize readBufSize = 0; do { @@ -953,11 +947,6 @@ std::string XPathIo::writeDataToFile(const std::string& orgPath) { if (prot == pStdin) { if (isatty(fileno(stdin))) throw Error(ErrorCode::kerInputDataReadFailed); -#ifdef _WIN32 - // convert stdin to binary - if (_setmode(_fileno(stdin), _O_BINARY) == -1) - throw Error(ErrorCode::kerInputDataReadFailed); -#endif std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc); // read stdin and write to the temp file. char readBuf[100 * 1024];