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 <[email protected]>
  • Loading branch information
neheb committed Aug 3, 2023
1 parent 4dfb781 commit 908e6eb
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 29 deletions.
13 changes: 0 additions & 13 deletions app/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,12 @@
#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 +186,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 +776,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 +1782,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
1 change: 0 additions & 1 deletion 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
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 908e6eb

Please sign in to comment.