mirror of https://github.com/aria2/aria2
add defines and macros to support MSVC
parent
99def35884
commit
731aec33db
|
@ -32,7 +32,7 @@ config_h_add_compile_definitions(BUILD="${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_H
|
|||
config_h_add_compile_definitions(TARGET="${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM}-${CMAKE_CXX_COMPILER_TARGET}")
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -D_POSIX_C_SOURCE=1)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_POSIX_C_SOURCE=1")
|
||||
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat)
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat)
|
||||
|
@ -79,6 +79,16 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
|||
# using Intel C++
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
# config_h_add_compile_definitions(__MSVC__=1) # USE _MSC_VER
|
||||
add_compile_definitions(NOMINMAX)
|
||||
config_h_add_compile_macro("__restrict__ __restrict")
|
||||
config_h_add_compile_macro("__attribute__(unused) /*Empty*/")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
set(NO_UNIX)
|
||||
config_h_add_compile_macro("mode_t int")
|
||||
config_h_add_compile_definitions(NO_UNIX=1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
|
@ -350,6 +360,8 @@ if(WITH_OPENSSL)
|
|||
|
||||
if(OPENSSL_FOUND AND NOT HAVE_SSL)
|
||||
set(HAVE_OPENSSL yes CACHE BOOL "Define is you have openssl" FORCE)
|
||||
set(OPENSSL_CFLAGS "")
|
||||
set(OPENSSL_LIBS ${OPENSSL_LIBRARIES})
|
||||
config_h_add_compile_definitions(HAVE_OPENSSL=1)
|
||||
|
||||
set(save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
|
|
|
@ -2,6 +2,10 @@ function(config_h_add_compile_definitions definitions)
|
|||
set(${PROJECT_NAME}_CONFIG_H_definitions ${${PROJECT_NAME}_CONFIG_H_definitions} ${definitions} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(config_h_add_compile_macro definitions)
|
||||
set(${PROJECT_NAME}_CONFIG_H_macros ${${PROJECT_NAME}_CONFIG_H_macros} ${definitions} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(config_h_generate_header name)
|
||||
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "/* config.h.in. Generated from cmake*/\n")
|
||||
foreach(def ${${PROJECT_NAME}_CONFIG_H_definitions})
|
||||
|
@ -18,5 +22,10 @@ function(config_h_generate_header name)
|
|||
endif()
|
||||
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "#define ${def_name} @${def_name}_config_h_val@\n" APPEND)
|
||||
endforeach()
|
||||
|
||||
foreach(macro ${${PROJECT_NAME}_CONFIG_H_macros})
|
||||
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "#define ${macro} \n" APPEND)
|
||||
endforeach()
|
||||
|
||||
configure_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in ${name}.h)
|
||||
endfunction()
|
|
@ -33,6 +33,27 @@ include(CheckIncludeFiles)
|
|||
include(CheckTypeSize)
|
||||
include(CheckFunctionExists)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# using Clang
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# using GCC
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -pipe)
|
||||
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
# using Intel C++
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
# config_h_add_compile_definitions(__MSVC__=1) # USE _MSC_VER
|
||||
add_compile_definitions(NOMINMAX)
|
||||
config_h_add_compile_macro("__restrict__ __restrict")
|
||||
config_h_add_compile_macro("__attribute__(unused) /*Empty*/")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
set(NO_UNIX)
|
||||
config_h_add_compile_definitions(NO_UNIX=1)
|
||||
endif()
|
||||
|
||||
|
||||
if(ENABLE_WERROR)
|
||||
add_compile_options(-Wall -Werror -Wformat-security)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
// g++ -Wall -O2 -g -o echoserv echoserv.cc -L../lib/.libs -I../lib/includes -lwslay -lnettle
|
||||
// $ export LD_LIBRARY_PATH=../lib/.libs
|
||||
// $ ./a.out 9000
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
* $ export LD_LIBRARY_PATH=../lib/.libs
|
||||
* $ ./a.out 9000
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
// $ g++ -Wall -O2 -g -o testclient testclient.cc -L../lib/.libs -I../lib/includes -lwslay -lnettle
|
||||
// $ export LD_LIBRARY_PATH=../lib/.libs
|
||||
// $ ./a.out localhost 9001
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
|
|
@ -33,6 +33,11 @@ extern "C" {
|
|||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wslay/wslayver.h is generated from wslay/wslayver.h.in by
|
||||
* configure. The projects which do not use autotools can set
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
/* copyright --> */
|
||||
#include "AbstractDiskWriter.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_MMAP
|
||||
# include <sys/mman.h>
|
||||
#endif // HAVE_MMAP
|
||||
|
@ -54,12 +56,16 @@
|
|||
#include "error_code.h"
|
||||
#include "LogFactory.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <winioctl.h>
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
AbstractDiskWriter::AbstractDiskWriter(const std::string& filename)
|
||||
: filename_(filename),
|
||||
fd_(A2_BAD_FD),
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
mapView_(0),
|
||||
#else // !__MINGW32__
|
||||
#endif // !__MINGW32__
|
||||
|
@ -78,7 +84,7 @@ namespace {
|
|||
// the value of GetLastError(). Otherwise, return errno.
|
||||
int fileError()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
return GetLastError();
|
||||
#else // !__MINGW32__
|
||||
return errno;
|
||||
|
@ -92,7 +98,7 @@ namespace {
|
|||
// errno.
|
||||
std::string fileStrerror(int errNum)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
auto msg = util::formatLastError(errNum);
|
||||
if (msg.empty()) {
|
||||
char buf[256];
|
||||
|
@ -113,7 +119,7 @@ void AbstractDiskWriter::openFile(int64_t totalLength)
|
|||
}
|
||||
catch (RecoverableException& e) {
|
||||
if (
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
e.getErrNum() == ERROR_FILE_NOT_FOUND ||
|
||||
e.getErrNum() == ERROR_PATH_NOT_FOUND
|
||||
#else // !__MINGW32__
|
||||
|
@ -133,7 +139,7 @@ void AbstractDiskWriter::closeFile()
|
|||
#if defined(HAVE_MMAP) || defined(__MINGW32__)
|
||||
if (mapaddr_) {
|
||||
int errNum = 0;
|
||||
# ifdef __MINGW32__
|
||||
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
if (!UnmapViewOfFile(mapaddr_)) {
|
||||
errNum = GetLastError();
|
||||
}
|
||||
|
@ -157,7 +163,7 @@ void AbstractDiskWriter::closeFile()
|
|||
}
|
||||
#endif // HAVE_MMAP || defined __MINGW32__
|
||||
if (fd_ != A2_BAD_FD) {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
CloseHandle(fd_);
|
||||
#else // !__MINGW32__
|
||||
close(fd_);
|
||||
|
@ -167,7 +173,7 @@ void AbstractDiskWriter::closeFile()
|
|||
}
|
||||
|
||||
namespace {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
HANDLE openFileWithFlags(const std::string& filename, int flags,
|
||||
error_code::Value errCode)
|
||||
{
|
||||
|
@ -265,7 +271,7 @@ ssize_t AbstractDiskWriter::writeDataInternal(const unsigned char* data,
|
|||
ssize_t writtenLength = 0;
|
||||
seek(offset);
|
||||
while ((size_t)writtenLength < len) {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
DWORD nwrite;
|
||||
if (WriteFile(fd_, data + writtenLength, len - writtenLength, &nwrite,
|
||||
0)) {
|
||||
|
@ -303,7 +309,7 @@ ssize_t AbstractDiskWriter::readDataInternal(unsigned char* data, size_t len,
|
|||
}
|
||||
else {
|
||||
seek(offset);
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
DWORD nread;
|
||||
if (ReadFile(fd_, data, len, &nread, 0)) {
|
||||
return nread;
|
||||
|
@ -323,7 +329,7 @@ ssize_t AbstractDiskWriter::readDataInternal(unsigned char* data, size_t len,
|
|||
void AbstractDiskWriter::seek(int64_t offset)
|
||||
{
|
||||
assert(offset >= 0);
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
LARGE_INTEGER fileLength;
|
||||
fileLength.QuadPart = offset;
|
||||
if (SetFilePointerEx(fd_, fileLength, 0, FILE_BEGIN) == 0)
|
||||
|
@ -345,7 +351,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
|
|||
if (mapaddr_) {
|
||||
if (static_cast<int64_t>(len + offset) > maplen_) {
|
||||
int errNum = 0;
|
||||
# ifdef __MINGW32__
|
||||
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
if (!UnmapViewOfFile(mapaddr_)) {
|
||||
errNum = GetLastError();
|
||||
}
|
||||
|
@ -385,7 +391,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
|
|||
|
||||
int errNum = 0;
|
||||
if (static_cast<int64_t>(len + offset) <= filesize) {
|
||||
# ifdef __MINGW32__
|
||||
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
mapView_ = CreateFileMapping(fd_, 0, PAGE_READWRITE, filesize >> 32,
|
||||
filesize & 0xffffffffu, 0);
|
||||
if (mapView_) {
|
||||
|
@ -432,7 +438,7 @@ namespace {
|
|||
bool isDiskFullError(int errNum)
|
||||
{
|
||||
return
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
errNum == ERROR_DISK_FULL || errNum == ERROR_HANDLE_DISK_FULL
|
||||
#else // !__MINGW32__
|
||||
errNum == ENOSPC
|
||||
|
@ -483,7 +489,7 @@ void AbstractDiskWriter::truncate(int64_t length)
|
|||
if (fd_ == A2_BAD_FD) {
|
||||
throw DL_ABORT_EX("File not yet opened.");
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// Since mingw32's ftruncate cannot handle over 2GB files, we use
|
||||
// SetEndOfFile instead.
|
||||
seek(length);
|
||||
|
@ -505,7 +511,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
|
|||
throw DL_ABORT_EX("File not yet opened.");
|
||||
}
|
||||
if (sparse) {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
DWORD bytesReturned;
|
||||
if (!DeviceIoControl(fd_, FSCTL_SET_SPARSE, 0, 0, 0, 0, &bytesReturned,
|
||||
0)) {
|
||||
|
@ -517,7 +523,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
|
|||
return;
|
||||
}
|
||||
#ifdef HAVE_SOME_FALLOCATE
|
||||
# ifdef __MINGW32__
|
||||
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
truncate(offset + length);
|
||||
if (!SetFileValidData(fd_, offset + length)) {
|
||||
auto errNum = fileError();
|
||||
|
@ -595,7 +601,7 @@ void AbstractDiskWriter::flushOSBuffers()
|
|||
if (fd_ == A2_BAD_FD) {
|
||||
return;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
FlushFileBuffers(fd_);
|
||||
#else // !__MINGW32__
|
||||
fsync(fd_);
|
||||
|
|
|
@ -44,7 +44,7 @@ class AbstractDiskWriter : public DiskWriter {
|
|||
private:
|
||||
std::string filename_;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
HANDLE fd_;
|
||||
// The handle for memory mapped file. mmap equivalent in Windows.
|
||||
HANDLE mapView_;
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void BtFileAllocationEntry::prepareForNextAction(
|
|||
}
|
||||
}
|
||||
else {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
if (!diskAdaptor->isReadOnlyEnabled()) {
|
||||
// On Windows, if aria2 opens files with GENERIC_WRITE access
|
||||
// right, some programs cannot open them aria2 is seeding. To
|
||||
|
|
|
@ -47,7 +47,7 @@ BufferedFile::BufferedFile(const char* filename, const char* mode)
|
|||
: fp_(strcmp(DEV_STDIN, filename) == 0
|
||||
? stdin
|
||||
:
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
|
||||
#else // !__MINGW32__
|
||||
a2fopen(filename, mode)
|
||||
|
@ -81,7 +81,7 @@ int BufferedFile::onClose()
|
|||
int rv = 0;
|
||||
if (fp_) {
|
||||
fflush(fp_);
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
fsync(fileno(fp_));
|
||||
#else // __MINGW32__
|
||||
_commit(fileno(fp_));
|
||||
|
|
|
@ -1282,6 +1282,7 @@ target_include_directories(aria2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/includes)
|
|||
|
||||
if(HAVE_ZLIB)
|
||||
target_include_directories(aria2 PUBLIC ${ZLIB_INCLUDE_DIRS})
|
||||
target_include_directories(main PUBLIC ${LIBXML2_INCLUDE_DIR})
|
||||
target_link_libraries(aria2 ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
|
@ -1292,16 +1293,19 @@ endif()
|
|||
|
||||
if(HAVE_LIBXML2)
|
||||
target_include_directories(aria2 PUBLIC ${LIBXML2_INCLUDE_DIR})
|
||||
target_include_directories(main PUBLIC ${LIBXML2_INCLUDE_DIR})
|
||||
target_link_libraries(aria2 LibXml2::LibXml2)
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBEXPAT)
|
||||
target_include_directories(aria2 PUBLIC ${EXPAT_INCLUDE_DIRS})
|
||||
target_include_directories(main PUBLIC ${EXPAT_INCLUDE_DIRS})
|
||||
target_link_libraries(aria2 EXPAT::EXPAT)
|
||||
endif()
|
||||
|
||||
if(HAVE_SQLITE3)
|
||||
target_include_directories(aria2 PUBLIC ${SQLite3_INCLUDE_DIRS})
|
||||
target_include_directories(main PUBLIC ${SQLite3_INCLUDE_DIRS})
|
||||
target_link_libraries(aria2 SQLite::SQLite3)
|
||||
endif()
|
||||
|
||||
|
@ -1316,11 +1320,15 @@ endif()
|
|||
if(HAVE_LIBGNUTLS)
|
||||
target_include_directories(aria2 PUBLIC ${GNUTLS_INCLUDE_DIR})
|
||||
target_compile_definitions(aria2 PUBLIC ${LIBGNUTLS_CFLAGS})
|
||||
target_include_directories(main PUBLIC ${GNUTLS_INCLUDE_DIR})
|
||||
target_compile_definitions(main PUBLIC ${LIBGNUTLS_CFLAGS})
|
||||
target_link_libraries(aria2 GnuTLS::GnuTLS)
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENSSL)
|
||||
target_include_directories(aria2 PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
target_include_directories(main PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(aria2 OpenSSL::SSL)
|
||||
|
||||
# target_link_libraries(aria2 INTERFACE OpenSSL::Crypto)
|
||||
|
@ -1328,21 +1336,25 @@ endif()
|
|||
|
||||
if(HAVE_LIBNETTLE)
|
||||
target_include_directories(aria2 PUBLIC ${NETTLE_INCLUDE_DIR})
|
||||
target_include_directories(main PUBLIC ${NETTLE_INCLUDE_DIR})
|
||||
target_link_libraries(aria2 Nettle::Nettle)
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBGMP)
|
||||
target_include_directories(aria2 PUBLIC ${GMP_INCLUDE_DIR})
|
||||
target_include_directories(main PUBLIC ${GMP_INCLUDE_DIR})
|
||||
target_link_libraries(aria2 GMP::GMP)
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBGCRYPT)
|
||||
target_include_directories(aria2 PUBLIC ${LibGcrypt_INCLUDE_DIR})
|
||||
target_include_directories(main PUBLIC ${LibGcrypt_INCLUDE_DIR})
|
||||
target_link_libraries(aria2 LibGcrypt::LibGcrypt)
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBSSH2)
|
||||
target_include_directories(aria2 PUBLIC ${LIBSSH2_INCLUDE_DIR})
|
||||
target_include_directories(main PUBLIC ${LIBSSH2_INCLUDE_DIR})
|
||||
target_link_libraries(aria2 LibSSH2::LibSSH2)
|
||||
endif()
|
||||
|
||||
|
@ -1353,6 +1365,7 @@ endif()
|
|||
|
||||
if(ENABLE_WEBSOCKET)
|
||||
target_include_directories(aria2 PUBLIC ${WSLAY_INCLUDE_DIR})
|
||||
target_include_directories(main PUBLIC ${WSLAY_INCLUDE_DIR})
|
||||
target_link_libraries(aria2 wslay)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -40,7 +40,9 @@
|
|||
#ifdef HAVE_SYS_IOCTL_H
|
||||
# include <sys/ioctl.h>
|
||||
#endif // HAVE_SYS_IOCTL_H
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <iomanip>
|
||||
|
@ -272,7 +274,7 @@ ConsoleStatCalc::ConsoleStatCalc(std::chrono::seconds summaryInterval,
|
|||
: summaryInterval_(std::move(summaryInterval)),
|
||||
readoutVisibility_(true),
|
||||
truncate_(true),
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
isTTY_(true),
|
||||
#else // !__MINGW32__
|
||||
isTTY_(isatty(STDOUT_FILENO) == 1),
|
||||
|
@ -301,7 +303,7 @@ void ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
|||
unsigned short int cols = 79;
|
||||
|
||||
if (isTTY_) {
|
||||
#ifndef __MINGW32__
|
||||
#if efined(__MINGW32__) || defined(_MSC_VER)
|
||||
# ifdef HAVE_TERMIOS_H
|
||||
struct winsize size;
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
/* copyright --> */
|
||||
#include "Context.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <getopt.h>
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
|
|
|
@ -485,7 +485,7 @@ void DefaultPieceStorage::completePiece(const std::shared_ptr<Piece>& piece)
|
|||
#ifdef ENABLE_BITTORRENT
|
||||
if (downloadContext_->hasAttribute(CTX_ATTR_BT)) {
|
||||
if (!bittorrent::getTorrentAttrs(downloadContext_)->metadata.empty()) {
|
||||
# ifdef __MINGW32__
|
||||
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// On Windows, if aria2 opens files with GENERIC_WRITE access
|
||||
// right, some programs cannot open them aria2 is seeding. To
|
||||
// avoid this situation, re-open the files with read-only
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
|
||||
#include "AbstractCommand.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ std::string usedCompilerAndPlatform()
|
|||
|
||||
#elif defined(__GNUG__)
|
||||
|
||||
# ifdef __MINGW32__
|
||||
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
rv << "mingw ";
|
||||
# ifdef __MINGW32_MAJOR_VERSION
|
||||
rv << (int)__MINGW32_MAJOR_VERSION;
|
||||
|
|
18
src/File.cc
18
src/File.cc
|
@ -39,7 +39,9 @@
|
|||
#ifdef HAVE_UTIME_H
|
||||
# include <utime.h>
|
||||
#endif // HAVE_UTIME_H
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
|
@ -120,7 +122,7 @@ bool File::remove()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
namespace {
|
||||
HANDLE openFile(const std::string& filename, bool readOnly = true)
|
||||
{
|
||||
|
@ -136,7 +138,7 @@ HANDLE openFile(const std::string& filename, bool readOnly = true)
|
|||
|
||||
int64_t File::size()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// _wstat cannot be used for symlink. It always returns 0. Quoted
|
||||
// from https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx:
|
||||
//
|
||||
|
@ -165,7 +167,7 @@ bool File::mkdirs()
|
|||
if (isDir()) {
|
||||
return false;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
std::string path = name_;
|
||||
for (std::string::iterator i = path.begin(), eoi = path.end(); i != eoi;
|
||||
++i) {
|
||||
|
@ -224,7 +226,7 @@ bool File::mkdirs()
|
|||
if (i != end) {
|
||||
++i;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
if (*(j - 1) == ':') {
|
||||
// This is a drive letter, e.g. C:, so skip it.
|
||||
continue;
|
||||
|
@ -289,7 +291,7 @@ bool File::isDir(const std::string& filename) { return File(filename).isDir(); }
|
|||
|
||||
bool File::renameTo(const std::string& dest)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// MinGW's rename() doesn't delete an existing destination. Better
|
||||
// to use MoveFileEx, which usually provides atomic move in aria2
|
||||
// usecase.
|
||||
|
@ -374,7 +376,7 @@ Time File::getModifiedTime()
|
|||
|
||||
std::string File::getCurrentDir()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
const size_t buflen = 2048;
|
||||
wchar_t buf[buflen];
|
||||
if (_wgetcwd(buf, buflen)) {
|
||||
|
@ -397,7 +399,7 @@ std::string File::getCurrentDir()
|
|||
|
||||
const char* File::getPathSeparators()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
return "/\\";
|
||||
#else // !__MINGW32__
|
||||
return "/";
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ int FtpConnection::receiveResponse()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define LONGLONG_PRINTF "%I64d"
|
||||
# define ULONGLONG_PRINTF "%I64u"
|
||||
# define LONGLONG_SCANF "%I64d"
|
||||
|
|
|
@ -50,7 +50,7 @@ GZipFile::GZipFile(const char* filename, const char* mode)
|
|||
strcmp(DEV_STDIN, filename) == 0
|
||||
? stdin
|
||||
:
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
|
||||
#else // !__MINGW32__
|
||||
a2fopen(filename, mode)
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
/* copyright --> */
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# ifdef _WIN32_WINNT
|
||||
# undef _WIN32_WINNT
|
||||
# endif // _WIN32_WINNT
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
/* copyright --> */
|
||||
#include "Logger.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
|
|
|
@ -59,7 +59,7 @@ bool LpdMessageReceiver::init(const std::string& localAddr)
|
|||
{
|
||||
try {
|
||||
socket_ = std::make_shared<SocketCore>(SOCK_DGRAM);
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// Binding multicast address fails under Windows.
|
||||
socket_->bindWithFamily(multicastPort_, AF_INET);
|
||||
#else // !__MINGW32__
|
||||
|
|
|
@ -231,7 +231,7 @@ int MultiUrlRequestInfo::prepare()
|
|||
auto authConfigFactory = make_unique<AuthConfigFactory>();
|
||||
File netrccf(option_->get(PREF_NETRC_PATH));
|
||||
if (!option_->getAsBool(PREF_NO_NETRC) && netrccf.isFile()) {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// Windows OS does not have permission, so set it to 0.
|
||||
mode_t mode = 0;
|
||||
#else // !__MINGW32__
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
/* copyright --> */
|
||||
#include "OptionParser.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <getopt.h>
|
||||
|
||||
#include <cstring>
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <memory>
|
||||
|
||||
#include "SocketBuffer.h"
|
||||
|
|
|
@ -182,7 +182,7 @@ bool Platform::setUp()
|
|||
}
|
||||
#endif // HAVE_WINSOCK2_H
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
(void)_setmode(_fileno(stdin), _O_BINARY);
|
||||
(void)_setmode(_fileno(stdout), _O_BINARY);
|
||||
(void)_setmode(_fileno(stderr), _O_BINARY);
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
#include "common.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
|
|
@ -619,7 +619,7 @@ void RequestGroup::initPieceStorage()
|
|||
std::make_shared<SegmentMan>(downloadContext_, tempPieceStorage);
|
||||
pieceStorage_ = tempPieceStorage;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// Windows build: --file-allocation=falloc uses SetFileValidData
|
||||
// which requires SE_MANAGE_VOLUME_NAME privilege. SetFileValidData
|
||||
// has security implications (see
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
/* copyright --> */
|
||||
#include "RequestGroupMan.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
/* copyright --> */
|
||||
#include "SelectEventPoll.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# include <cassert>
|
||||
#endif // __MINGW32__
|
||||
#include <cstring>
|
||||
|
@ -153,7 +153,7 @@ void SelectEventPoll::AsyncNameResolverEntry::process(fd_set* rfdsPtr,
|
|||
|
||||
SelectEventPoll::SelectEventPoll()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
dummySocket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
assert(dummySocket_ != (sock_t)-1);
|
||||
#endif // __MINGW32__
|
||||
|
@ -162,7 +162,7 @@ SelectEventPoll::SelectEventPoll()
|
|||
|
||||
SelectEventPoll::~SelectEventPoll()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
::closesocket(dummySocket_);
|
||||
#endif // __MINGW32__
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
|||
memcpy(&rfds, &rfdset_, sizeof(fd_set));
|
||||
memcpy(&wfds, &wfdset_, sizeof(fd_set));
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
fd_set efds;
|
||||
memcpy(&efds, &wfdset_, sizeof(fd_set));
|
||||
#endif // __MINGW32__
|
||||
|
@ -195,7 +195,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
|||
int retval;
|
||||
do {
|
||||
struct timeval ttv = tv;
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// winsock will report non-blocking connect() errors in efds,
|
||||
// unlike posix, which will mark such sockets as writable.
|
||||
retval = select(fdmax_ + 1, &rfds, &wfds, &efds, &ttv);
|
||||
|
@ -213,7 +213,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
|||
if (FD_ISSET(e.getSocket(), &wfds)) {
|
||||
events |= EventPoll::EVENT_WRITE;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
if (FD_ISSET(e.getSocket(), &efds)) {
|
||||
events |= EventPoll::EVENT_ERROR;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
|||
#endif // ENABLE_ASYNC_DNS
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
namespace {
|
||||
void checkFdCountMingw(const fd_set& fdset)
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ void SelectEventPoll::updateFdSet()
|
|||
{
|
||||
FD_ZERO(&rfdset_);
|
||||
FD_ZERO(&wfdset_);
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
FD_SET(dummySocket_, &rfdset_);
|
||||
FD_SET(dummySocket_, &wfdset_);
|
||||
fdmax_ = dummySocket_;
|
||||
|
@ -262,7 +262,7 @@ void SelectEventPoll::updateFdSet()
|
|||
for (auto& i : socketEntries_) {
|
||||
auto& e = i.second;
|
||||
sock_t fd = e.getSocket();
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
if (fd < 0 || FD_SETSIZE <= fd) {
|
||||
A2_LOG_WARN("Detected file descriptor >= FD_SETSIZE or < 0. "
|
||||
"Download may slow down or fail.");
|
||||
|
@ -271,13 +271,13 @@ void SelectEventPoll::updateFdSet()
|
|||
#endif // !__MINGW32__
|
||||
int events = e.getEvents();
|
||||
if (events & EventPoll::EVENT_READ) {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
checkFdCountMingw(rfdset_);
|
||||
#endif // __MINGW32__
|
||||
FD_SET(fd, &rfdset_);
|
||||
}
|
||||
if (events & EventPoll::EVENT_WRITE) {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
checkFdCountMingw(wfdset_);
|
||||
#endif // __MINGW32__
|
||||
FD_SET(fd, &wfdset_);
|
||||
|
|
|
@ -151,7 +151,7 @@ private:
|
|||
fd_set rfdset_;
|
||||
fd_set wfdset_;
|
||||
sock_t fdmax_;
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// Winsock select() doesn't work if no socket is in FD_SET. We add
|
||||
// this dummy socket to work around this problem
|
||||
sock_t dummySocket_;
|
||||
|
|
|
@ -35,7 +35,11 @@
|
|||
#include "SimpleRandomizer.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
@ -66,7 +70,7 @@ namespace {
|
|||
std::random_device rd;
|
||||
} // namespace
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
SimpleRandomizer::SimpleRandomizer()
|
||||
{
|
||||
BOOL r = ::CryptAcquireContext(&provider_, 0, 0, PROV_RSA_FULL,
|
||||
|
@ -79,7 +83,7 @@ SimpleRandomizer::SimpleRandomizer() : gen_(rd()) {}
|
|||
|
||||
SimpleRandomizer::~SimpleRandomizer()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
CryptReleaseContext(provider_, 0);
|
||||
#endif
|
||||
}
|
||||
|
@ -92,7 +96,7 @@ long int SimpleRandomizer::getRandomNumber(long int to)
|
|||
|
||||
void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
BOOL r = CryptGenRandom(provider_, len, reinterpret_cast<BYTE*>(buf));
|
||||
if (!r) {
|
||||
assert(r);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <memory>
|
||||
#include <random>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# include <wincrypt.h>
|
||||
#endif
|
||||
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
SimpleRandomizer();
|
||||
|
||||
private:
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
HCRYPTPROV provider_;
|
||||
#else
|
||||
std::mt19937 gen_;
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
# include <iphlpapi.h>
|
||||
#endif // HAVE_IPHLPAPI_H
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_IFADDRS_H
|
||||
# include <ifaddrs.h>
|
||||
#endif // HAVE_IFADDRS_H
|
||||
|
@ -68,13 +70,13 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define SOCKET_ERRNO (errno)
|
||||
#else
|
||||
# define SOCKET_ERRNO (WSAGetLastError())
|
||||
#endif // __MINGW32__
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define A2_EINPROGRESS WSAEWOULDBLOCK
|
||||
# define A2_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
# define A2_EINTR WSAEINTR
|
||||
|
@ -93,7 +95,7 @@ namespace aria2 {
|
|||
# endif // EWOULDBLOCK != EAGAIN
|
||||
#endif // !__MINGW32__
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define CLOSE(X) ::closesocket(X)
|
||||
#else
|
||||
# define CLOSE(X) close(X)
|
||||
|
@ -102,7 +104,7 @@ namespace aria2 {
|
|||
namespace {
|
||||
std::string errorMsg(int errNum)
|
||||
{
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
return util::safeStrerror(errNum);
|
||||
#else
|
||||
auto msg = util::formatLastError(errNum);
|
||||
|
@ -595,7 +597,7 @@ void SocketCore::applyIpDscp()
|
|||
|
||||
void SocketCore::setNonBlockingMode()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
static u_long flag = 1;
|
||||
if (::ioctlsocket(sockfd_, FIONBIO, &flag) == -1) {
|
||||
int errNum = SOCKET_ERRNO;
|
||||
|
@ -614,7 +616,7 @@ void SocketCore::setNonBlockingMode()
|
|||
|
||||
void SocketCore::setBlockingMode()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
static u_long flag = 0;
|
||||
if (::ioctlsocket(sockfd_, FIONBIO, &flag) == -1) {
|
||||
int errNum = SOCKET_ERRNO;
|
||||
|
@ -654,7 +656,7 @@ void SocketCore::closeConnection()
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define CHECK_FD(fd) \
|
||||
if (fd < 0 || FD_SETSIZE <= fd) { \
|
||||
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
|
||||
|
@ -681,7 +683,7 @@ bool SocketCore::isWritable(time_t timeout)
|
|||
}
|
||||
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
|
||||
#else // !HAVE_POLL
|
||||
# ifndef __MINGW32__
|
||||
# ifn defined(__MINGW32__) || defined(_MSC_VER)
|
||||
CHECK_FD(sockfd_);
|
||||
# endif // !__MINGW32__
|
||||
fd_set fds;
|
||||
|
@ -726,7 +728,7 @@ bool SocketCore::isReadable(time_t timeout)
|
|||
}
|
||||
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
|
||||
#else // !HAVE_POLL
|
||||
# ifndef __MINGW32__
|
||||
# ifn defined(__MINGW32__) || defined(_MSC_VER)
|
||||
CHECK_FD(sockfd_);
|
||||
# endif // !__MINGW32__
|
||||
fd_set fds;
|
||||
|
@ -759,7 +761,7 @@ ssize_t SocketCore::writeVector(a2iovec* iov, size_t iovcnt)
|
|||
wantRead_ = false;
|
||||
wantWrite_ = false;
|
||||
if (!secure_) {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
DWORD nsent;
|
||||
int rv = WSASend(sockfd_, iov, iovcnt, &nsent, 0, 0, 0);
|
||||
if (rv == 0) {
|
||||
|
@ -1572,7 +1574,7 @@ bool ipv4AddrConfigured = true;
|
|||
bool ipv6AddrConfigured = true;
|
||||
} // namespace
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
namespace {
|
||||
const uint32_t APIPA_IPV4_BEGIN = 2851995649u; // 169.254.0.1
|
||||
const uint32_t APIPA_IPV4_END = 2852061183u; // 169.254.255.255
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
#include "common.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
#ifdef HAVE_POLL_H
|
||||
|
@ -120,7 +122,7 @@
|
|||
# define DEV_STDOUT "/dev/stdout"
|
||||
#endif // HAVE_WINSOCK2_H
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin)
|
||||
# define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin)
|
||||
# define a2fstat(fd, buf) _fstati64(fd, buf)
|
||||
|
@ -190,7 +192,7 @@ extern int ftruncate64(int fd, off64_t length);
|
|||
#define OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
|
||||
#define DIR_OPEN_MODE S_IRWXU | S_IRWXG | S_IRWXO
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define A2_BAD_FD INVALID_HANDLE_VALUE
|
||||
#else // !__MINGW32__
|
||||
# define A2_BAD_FD -1
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
|
||||
#include "a2io.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# ifdef HAVE_WS2TCPIP_H
|
||||
# include <ws2tcpip.h>
|
||||
# endif // HAVE_WS2TCPIP_H
|
||||
#endif // __MINGW32__
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define a2_sockopt_t char*
|
||||
# ifndef HAVE_GETADDRINFO
|
||||
# define HAVE_GETADDRINFO
|
||||
|
@ -95,6 +95,7 @@
|
|||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
# define sock_t SOCKET
|
||||
# include <ws2def.h>
|
||||
#else
|
||||
# define sock_t int
|
||||
#endif
|
||||
|
@ -105,7 +106,7 @@
|
|||
|
||||
#define DEFAULT_AI_FLAGS AI_ADDRCONFIG
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# ifndef SHUT_WR
|
||||
# define SHUT_WR SD_SEND
|
||||
# endif // !SHUT_WR
|
||||
|
@ -141,7 +142,7 @@ struct Endpoint {
|
|||
# define A2_IOV_MAX A2_DEFAULT_IOV_MAX
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
typedef WSABUF a2iovec;
|
||||
# define A2IOVEC_BASE buf
|
||||
# define A2IOVEC_LEN len
|
||||
|
|
|
@ -36,7 +36,10 @@
|
|||
#define D_A2TIME_H
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
|
||||
|
@ -60,7 +63,7 @@
|
|||
# include "asctime_r.h"
|
||||
#endif // HAVE_ASCTIME_R
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define suseconds_t uint64_t
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@
|
|||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif // __MINGW32__
|
||||
|
||||
#include "asctime_r.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|
||||
static CRITICAL_SECTION asctime_r_cs;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# ifdef malloc
|
||||
# undef malloc
|
||||
# endif
|
||||
|
@ -48,7 +48,12 @@
|
|||
# endif
|
||||
#endif // __MINGW32__
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(_MSC_VER)
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# ifndef WINVER
|
||||
# define WINVER 0x501
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
/* copyright --> */
|
||||
#include "console.h"
|
||||
#include "NullOutputFile.h"
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# include "WinConsoleFile.h"
|
||||
#else // !__MINGW32__
|
||||
# include "BufferedFile.h"
|
||||
|
@ -56,7 +56,7 @@ void initConsole(bool suppress)
|
|||
consoleCout = consoleCerr = std::make_shared<NullOutputFile>();
|
||||
}
|
||||
else {
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
consoleCout = std::make_shared<WinConsoleFile>(STD_OUTPUT_HANDLE);
|
||||
consoleCerr = std::make_shared<WinConsoleFile>(STD_ERROR_HANDLE);
|
||||
#else // !__MINGW32__
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
/* copyright --> */
|
||||
#include "daemon.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
namespace aria2 {
|
||||
|
||||
std::string fmt(const char* fmt, ...)
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
__attribute__((format(__MINGW_PRINTF_FORMAT, 1, 2)))
|
||||
#else // !__MINGW32__
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# undef SIZE_MAX
|
||||
#endif // __MINGW32__
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# include <winsock2.h>
|
||||
# undef ERROR
|
||||
# include <ws2tcpip.h>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# undef SIZE_MAX
|
||||
#endif // __MINGW32__
|
||||
|
||||
|
@ -41,7 +41,7 @@ extern "C" {
|
|||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(__MSVC__)
|
||||
# ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x501
|
||||
# endif // _WIN32_WINNT
|
||||
|
@ -240,7 +240,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Nexenta OS(GNU/Solaris OS) defines `struct addrinfo' in netdb.h */
|
||||
#if !defined(__MINGW32__) && !defined(__sun)
|
||||
#if !defined(__MINGW32__) && !defined(__sun) && !defined(_MSC_VER)
|
||||
|
||||
/*
|
||||
* struct addrinfo.
|
||||
|
@ -256,7 +256,7 @@ struct addrinfo {
|
|||
struct addrinfo* ai_next;
|
||||
};
|
||||
|
||||
#endif // !__MINGW32__ && !__sun
|
||||
#endif // !__MINGW32__ && !__sun && !defined(_MSC_VER)
|
||||
|
||||
/*
|
||||
* Functions.
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#ifndef _D_GETTIMEOFDAY_H
|
||||
#define _D_GETTIMEOFDAY_H 1
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# undef SIZE_MAX
|
||||
#endif // __MINGW32__
|
||||
|
||||
|
@ -44,7 +44,9 @@
|
|||
# include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|
||||
char* basename(char* path);
|
||||
char* dirname(char* path);
|
||||
|
|
|
@ -36,14 +36,14 @@
|
|||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif // __MINGW32__
|
||||
|
||||
#include "localtime_r.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|
||||
static CRITICAL_SECTION localtime_r_cs;
|
||||
|
||||
|
|
|
@ -34,9 +34,11 @@
|
|||
/* copyright --> */
|
||||
#include "common.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef NO_UNIX
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# include <shellapi.h>
|
||||
#endif // __MINGW32__
|
||||
|
||||
|
@ -53,7 +55,7 @@ namespace aria2 {
|
|||
|
||||
error_code::Value main(int argc, char** argv)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
int winArgc;
|
||||
auto winArgv = CommandLineToArgvW(GetCommandLineW(), &winArgc);
|
||||
if (winArgv == nullptr) {
|
||||
|
|
20
src/util.cc
20
src/util.cc
|
@ -96,7 +96,7 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
namespace {
|
||||
int utf8ToWChar(wchar_t* out, size_t outLength, const char* src)
|
||||
{
|
||||
|
@ -1742,7 +1742,7 @@ void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler,
|
|||
#endif // HAVE_SIGACTION
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
std::string getHomeDir()
|
||||
{
|
||||
const char* p = getenv("HOME");
|
||||
|
@ -1789,7 +1789,7 @@ std::string getXDGDir(const std::string& environmentVariable,
|
|||
std::string filename;
|
||||
const char* p = getenv(environmentVariable.c_str());
|
||||
if (p &&
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
p[0] == '/'
|
||||
#else // __MINGW32__
|
||||
p[0] && p[1] == ':'
|
||||
|
@ -2112,7 +2112,7 @@ std::string applyDir(const std::string& dir, const std::string& relPath)
|
|||
s += relPath;
|
||||
}
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
for (std::string::iterator i = s.begin(), eoi = s.end(); i != eoi; ++i) {
|
||||
if (*i == '\\') {
|
||||
*i = '/';
|
||||
|
@ -2179,7 +2179,7 @@ bool detectDirTraversal(const std::string& s)
|
|||
std::string escapePath(const std::string& s)
|
||||
{
|
||||
// We don't escape '/' because we use it as a path separator.
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
static const char WIN_INVALID_PATH_CHARS[] = {'"', '*', ':', '<',
|
||||
'>', '?', '\\', '|'};
|
||||
#endif // __MINGW32__
|
||||
|
@ -2187,7 +2187,7 @@ std::string escapePath(const std::string& s)
|
|||
for (auto cc : s) {
|
||||
unsigned char c = cc;
|
||||
if (in(c, 0x00u, 0x1fu) || c == 0x7fu
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|| std::find(std::begin(WIN_INVALID_PATH_CHARS),
|
||||
std::end(WIN_INVALID_PATH_CHARS),
|
||||
c) != std::end(WIN_INVALID_PATH_CHARS)
|
||||
|
@ -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 numFilesStr = util::uitos(numFiles);
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
A2_LOG_INFO(fmt("Executing user command: %s %s %s %s", command.c_str(),
|
||||
gidStr.c_str(), numFilesStr.c_str(), firstFilename.c_str()));
|
||||
pid_t cpid = fork();
|
||||
|
@ -2483,7 +2483,7 @@ TLSVersion toTLSVersion(const std::string& ver)
|
|||
}
|
||||
#endif // ENABLE_SSL
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
std::string formatLastError(int errNum)
|
||||
{
|
||||
std::array<char, 4_k> buf;
|
||||
|
@ -2502,7 +2502,7 @@ std::string formatLastError(int errNum)
|
|||
|
||||
void make_fd_cloexec(int fd)
|
||||
{
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
int flags;
|
||||
|
||||
// TODO from linux man page, fcntl() with F_GETFD or F_SETFD does
|
||||
|
@ -2519,7 +2519,7 @@ void make_fd_cloexec(int fd)
|
|||
#endif // !__MINGW32__
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
bool gainPrivilege(LPCTSTR privName)
|
||||
{
|
||||
LUID luid;
|
||||
|
|
16
src/util.h
16
src/util.h
|
@ -37,7 +37,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -95,7 +97,7 @@ inline uint64_t ntoh64(uint64_t x) { return byteswap64(x); }
|
|||
inline uint64_t hton64(uint64_t x) { return byteswap64(x); }
|
||||
#endif // !WORDS_BIGENDIAN
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
std::wstring utf8ToWChar(const std::string& src);
|
||||
|
||||
std::wstring utf8ToWChar(const char* str);
|
||||
|
@ -109,6 +111,12 @@ std::string toForwardSlash(const std::string& src);
|
|||
# define utf8ToNative(src) src
|
||||
#endif // !__MINGW32__
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
|
||||
namespace util {
|
||||
|
||||
extern const char DEFAULT_STRIP_CHARSET[];
|
||||
|
@ -863,7 +871,7 @@ bool tlsHostnameMatch(const std::string& pattern, const std::string& hostname);
|
|||
TLSVersion toTLSVersion(const std::string& ver);
|
||||
#endif // ENABLE_SSL
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
// Formats error message for error code errNum, which is the return
|
||||
// value of GetLastError(). On error, this function returns empty
|
||||
// string.
|
||||
|
@ -875,7 +883,7 @@ std::string formatLastError(int errNum);
|
|||
// CreateProcess call.
|
||||
void make_fd_cloexec(int fd);
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
bool gainPrivilege(LPCTSTR privName);
|
||||
#endif // __MINGW32__
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ void FileTest::testRemove()
|
|||
CPPUNIT_ASSERT(!f.remove());
|
||||
|
||||
std::string dir = A2_TEST_OUT_DIR "/aria2_FileTest_testRemove_testdir";
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
mkdir(dir.c_str());
|
||||
#else
|
||||
mkdir(dir.c_str(), 0777);
|
||||
|
@ -183,7 +183,7 @@ void FileTest::testGetDirname()
|
|||
File f("");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), f.getDirname());
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
{
|
||||
File f("c:\\foo\\bar");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("c:\\foo"), f.getDirname());
|
||||
|
@ -221,7 +221,7 @@ void FileTest::testGetBasename()
|
|||
File f("");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), f.getBasename());
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
{
|
||||
File f("c:\\foo\\bar");
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("bar"), f.getBasename());
|
||||
|
|
|
@ -44,7 +44,7 @@ void LpdMessageDispatcherTest::testCreateLpdRequest()
|
|||
void LpdMessageDispatcherTest::testSendMessage()
|
||||
{
|
||||
std::shared_ptr<SocketCore> recvsock(new SocketCore(SOCK_DGRAM));
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
recvsock->bindWithFamily(LPD_MULTICAST_PORT, AF_INET);
|
||||
#else // !__MINGW32__
|
||||
recvsock->bind(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, AF_INET);
|
||||
|
|
|
@ -208,7 +208,7 @@ void Metalink2RequestGroupTest::testGenerate_groupByMetaurl()
|
|||
|
||||
void Metalink2RequestGroupTest::testGenerate_dosDirTraversal()
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
# ifdef ENABLE_BITTORRENT
|
||||
std::vector<std::shared_ptr<RequestGroup>> groups;
|
||||
option_->put(PREF_DIR, "/tmp");
|
||||
|
|
|
@ -96,7 +96,7 @@ void TimeTest::testToHTTPDate()
|
|||
{
|
||||
// This test disabled for MinGW32, because the garbage will be
|
||||
// displayed and it hides real errors.
|
||||
#ifndef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
Time t(1220714793);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Sat, 06 Sep 2008 15:26:33 GMT"),
|
||||
t.toHTTPDate());
|
||||
|
|
|
@ -789,7 +789,7 @@ void UtilTest2::testApplyDir()
|
|||
void UtilTest2::testFixTaintedBasename()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("a%2Fb"), util::fixTaintedBasename("a/b"));
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("a%5Cb"), util::fixTaintedBasename("a\\b"));
|
||||
#else // !__MINGW32__
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("a\\b"), util::fixTaintedBasename("a\\b"));
|
||||
|
@ -827,7 +827,7 @@ void UtilTest2::testEscapePath()
|
|||
util::escapePath(std::string("foo") + (char)0x00 +
|
||||
std::string("bar") + (char)0x00 +
|
||||
(char)0x01));
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("foo%5Cbar"), util::escapePath("foo\\bar"));
|
||||
#else // !__MINGW32__
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("foo\\bar"), util::escapePath("foo\\bar"));
|
||||
|
|
Loading…
Reference in New Issue