mirror of https://github.com/aria2/aria2
fix inverted windows detection logic and typo
parent
549d8ffea1
commit
c7e5767a11
|
@ -81,7 +81,7 @@ int BufferedFile::onClose()
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
if (fp_) {
|
if (fp_) {
|
||||||
fflush(fp_);
|
fflush(fp_);
|
||||||
#if defined(__MINGW32__)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
fsync(fileno(fp_));
|
fsync(fileno(fp_));
|
||||||
#else // __MINGW32__
|
#else // __MINGW32__
|
||||||
_commit(fileno(fp_));
|
_commit(fileno(fp_));
|
||||||
|
|
|
@ -303,20 +303,20 @@ void ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
unsigned short int cols = 79;
|
unsigned short int cols = 79;
|
||||||
|
|
||||||
if (isTTY_) {
|
if (isTTY_) {
|
||||||
#if efined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
# ifdef HAVE_TERMIOS_H
|
# ifdef HAVE_TERMIOS_H
|
||||||
struct winsize size;
|
struct winsize size;
|
||||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
|
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
|
||||||
cols = std::max(0, (int)size.ws_col - 1);
|
cols = std::max(0, (int)size.ws_col - 1);
|
||||||
}
|
}
|
||||||
# endif // HAVE_TERMIOS_H
|
# endif // HAVE_TERMIOS_H
|
||||||
#else // __MINGW32__
|
#else // __MINGW32__ || _MSC_VER
|
||||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||||
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE),
|
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
&info)) {
|
&info)) {
|
||||||
cols = std::max(0, info.dwSize.X - 2);
|
cols = std::max(0, info.dwSize.X - 2);
|
||||||
}
|
}
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__ && !_MSC_VER
|
||||||
std::string line(cols, ' ');
|
std::string line(cols, ' ');
|
||||||
global::cout()->printf("\r%s\r", line.c_str());
|
global::cout()->printf("\r%s\r", line.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,13 +262,13 @@ void SelectEventPoll::updateFdSet()
|
||||||
for (auto& i : socketEntries_) {
|
for (auto& i : socketEntries_) {
|
||||||
auto& e = i.second;
|
auto& e = i.second;
|
||||||
sock_t fd = e.getSocket();
|
sock_t fd = e.getSocket();
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
if (fd < 0 || FD_SETSIZE <= fd) {
|
if (fd < 0 || FD_SETSIZE <= fd) {
|
||||||
A2_LOG_WARN("Detected file descriptor >= FD_SETSIZE or < 0. "
|
A2_LOG_WARN("Detected file descriptor >= FD_SETSIZE or < 0. "
|
||||||
"Download may slow down or fail.");
|
"Download may slow down or fail.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__ && !_MSC_VER
|
||||||
int events = e.getEvents();
|
int events = e.getEvents();
|
||||||
if (events & EventPoll::EVENT_READ) {
|
if (events & EventPoll::EVENT_READ) {
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
#ifndef NO_UNIX
|
#ifndef NO_UNIX
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
# define SOCKET_ERRNO (errno)
|
# define SOCKET_ERRNO (errno)
|
||||||
#else
|
#else
|
||||||
# define SOCKET_ERRNO (WSAGetLastError())
|
# define SOCKET_ERRNO (WSAGetLastError())
|
||||||
|
@ -104,7 +104,7 @@ namespace aria2 {
|
||||||
namespace {
|
namespace {
|
||||||
std::string errorMsg(int errNum)
|
std::string errorMsg(int errNum)
|
||||||
{
|
{
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
return util::safeStrerror(errNum);
|
return util::safeStrerror(errNum);
|
||||||
#else
|
#else
|
||||||
auto msg = util::formatLastError(errNum);
|
auto msg = util::formatLastError(errNum);
|
||||||
|
@ -656,7 +656,7 @@ void SocketCore::closeConnection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
# define CHECK_FD(fd) \
|
# define CHECK_FD(fd) \
|
||||||
if (fd < 0 || FD_SETSIZE <= fd) { \
|
if (fd < 0 || FD_SETSIZE <= fd) { \
|
||||||
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
|
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
|
||||||
|
@ -683,7 +683,7 @@ bool SocketCore::isWritable(time_t timeout)
|
||||||
}
|
}
|
||||||
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
|
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
|
||||||
#else // !HAVE_POLL
|
#else // !HAVE_POLL
|
||||||
# ifn defined(__MINGW32__) || defined(_MSC_VER)
|
# if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
CHECK_FD(sockfd_);
|
CHECK_FD(sockfd_);
|
||||||
# endif // !__MINGW32__
|
# endif // !__MINGW32__
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
@ -728,7 +728,7 @@ bool SocketCore::isReadable(time_t timeout)
|
||||||
}
|
}
|
||||||
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
|
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
|
||||||
#else // !HAVE_POLL
|
#else // !HAVE_POLL
|
||||||
# ifn defined(__MINGW32__) || defined(_MSC_VER)
|
# if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
CHECK_FD(sockfd_);
|
CHECK_FD(sockfd_);
|
||||||
# endif // !__MINGW32__
|
# endif // !__MINGW32__
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
|
|
@ -1742,7 +1742,7 @@ void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler,
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
std::string getHomeDir()
|
std::string getHomeDir()
|
||||||
{
|
{
|
||||||
const char* p = getenv("HOME");
|
const char* p = getenv("HOME");
|
||||||
|
@ -1789,7 +1789,7 @@ std::string getXDGDir(const std::string& environmentVariable,
|
||||||
std::string filename;
|
std::string filename;
|
||||||
const char* p = getenv(environmentVariable.c_str());
|
const char* p = getenv(environmentVariable.c_str());
|
||||||
if (p &&
|
if (p &&
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
p[0] == '/'
|
p[0] == '/'
|
||||||
#else // __MINGW32__
|
#else // __MINGW32__
|
||||||
p[0] && p[1] == ':'
|
p[0] && p[1] == ':'
|
||||||
|
@ -2234,7 +2234,7 @@ void executeHook(const std::string& command, a2_gid_t gid, size_t numFiles,
|
||||||
{
|
{
|
||||||
const std::string gidStr = GroupId::toHex(gid);
|
const std::string gidStr = GroupId::toHex(gid);
|
||||||
const std::string numFilesStr = util::uitos(numFiles);
|
const std::string numFilesStr = util::uitos(numFiles);
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
A2_LOG_INFO(fmt("Executing user command: %s %s %s %s", command.c_str(),
|
A2_LOG_INFO(fmt("Executing user command: %s %s %s %s", command.c_str(),
|
||||||
gidStr.c_str(), numFilesStr.c_str(), firstFilename.c_str()));
|
gidStr.c_str(), numFilesStr.c_str(), firstFilename.c_str()));
|
||||||
pid_t cpid = fork();
|
pid_t cpid = fork();
|
||||||
|
@ -2502,7 +2502,7 @@ std::string formatLastError(int errNum)
|
||||||
|
|
||||||
void make_fd_cloexec(int fd)
|
void make_fd_cloexec(int fd)
|
||||||
{
|
{
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// TODO from linux man page, fcntl() with F_GETFD or F_SETFD does
|
// TODO from linux man page, fcntl() with F_GETFD or F_SETFD does
|
||||||
|
|
|
@ -96,7 +96,7 @@ void TimeTest::testToHTTPDate()
|
||||||
{
|
{
|
||||||
// This test disabled for MinGW32, because the garbage will be
|
// This test disabled for MinGW32, because the garbage will be
|
||||||
// displayed and it hides real errors.
|
// displayed and it hides real errors.
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
Time t(1220714793);
|
Time t(1220714793);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("Sat, 06 Sep 2008 15:26:33 GMT"),
|
CPPUNIT_ASSERT_EQUAL(std::string("Sat, 06 Sep 2008 15:26:33 GMT"),
|
||||||
t.toHTTPDate());
|
t.toHTTPDate());
|
||||||
|
|
Loading…
Reference in New Issue