Skip to content

Commit

Permalink
remove useless code
Browse files Browse the repository at this point in the history
UCRT has obsoleted all of this

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Aug 3, 2023
1 parent 4dfb781 commit 81e3ed9
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 35 deletions.
14 changes: 0 additions & 14 deletions app/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,11 @@
#endif

#if defined(_WIN32)
#include <fcntl.h>
#include <io.h>
#include <sys/utime.h>
#include <windows.h>
#else
#include <utime.h>
#endif

#ifndef _WIN32
#define _setmode(a, b) \
do { \
} while (false)
#endif

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
Expand Down Expand Up @@ -194,7 +185,6 @@ static int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const st
}
}
} else {
_setmode(fileno(stdout), O_BINARY);
result = printStructure(std::cout, option, path);
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions app/exiv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <regex>

#if defined(_WIN32)
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#else
#include <sys/select.h>
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions samples/geotag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace fs = std::experimental::filesystem;

#ifdef _WIN32
#include <windows.h>
char* realpath(const char* file, char* path);
#define lstat stat
#if _MSC_VER < 1400
#define strcpy_s(d, l, s) strcpy(d, s)
Expand Down Expand Up @@ -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));
Expand Down
11 changes: 0 additions & 11 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 81e3ed9

Please sign in to comment.