diff --git a/ChangeLog b/ChangeLog index d6d3c1e73..3e8363e94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * fix mingw build for linux crosscompiler + 0.16.3 release * fix python binding backwards compatibility in replace_trackers diff --git a/include/libtorrent/GeoIP.h b/include/libtorrent/GeoIP.h index 74d5c66c7..420a22de0 100644 --- a/include/libtorrent/GeoIP.h +++ b/include/libtorrent/GeoIP.h @@ -29,7 +29,6 @@ extern "C" { #include #include #include /* for fstat */ -#include /* for fstat */ #define SEGMENT_RECORD_LENGTH 3 #define STANDARD_RECORD_LENGTH 3 diff --git a/include/libtorrent/alloca.hpp b/include/libtorrent/alloca.hpp index 11a05ef17..2ea74a979 100644 --- a/include/libtorrent/alloca.hpp +++ b/include/libtorrent/alloca.hpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#if defined TORRENT_WINDOWS +#if defined TORRENT_WINDOWS || defined TORRENT_MINGW #include #define TORRENT_ALLOCA(t, n) static_cast(_alloca(sizeof(t) * (n))) @@ -52,5 +52,3 @@ POSSIBILITY OF SUCH DAMAGE. #endif #endif - - diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index ad9c820ad..ad424420e 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -51,8 +51,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/intrusive_ptr_base.hpp" -#include - #ifdef TORRENT_WINDOWS // windows part #ifndef WIN32_LEAN_AND_MEAN @@ -93,16 +91,18 @@ namespace libtorrent time_t ctime; enum { #if defined TORRENT_WINDOWS - directory = _S_IFDIR, - regular_file = _S_IFREG + fifo = 0x1000, // named pipe (fifo) + character_special = 0x2000, // character special + directory = 0x4000, // directory + regular_file = 0x8000 // regular #else - fifo = S_IFIFO, - character_special = S_IFCHR, - directory = S_IFDIR, - block_special = S_IFBLK, - regular_file = S_IFREG, - link = S_IFLNK, - socket = S_IFSOCK + fifo = 0010000, // named pipe (fifo) + character_special = 0020000, // character special + directory = 0040000, // directory + block_special = 0060000, // block special + regular_file = 0100000, // regular + link = 0120000, // symbolic link + socket = 0140000 // socket #endif } modes_t; int mode; diff --git a/src/file.cpp b/src/file.cpp index 9bbefb46c..2cd44e8ec 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -43,6 +43,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include + #ifdef TORRENT_WINDOWS // windows part @@ -57,16 +59,18 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include #include +#ifndef TORRENT_MINGW #include // for _getcwd, _mkdir +#else +#include +#endif #include -#include #else // posix part #define _FILE_OFFSET_BITS 64 #include #include // for F_LOG2PHYS -#include #include #include #include @@ -167,7 +171,7 @@ namespace libtorrent std::string f = convert_to_native(inf); #endif -#ifdef TORRENT_WINDOWS +#if defined TORRENT_WINDOWS struct _stati64 ret; #if TORRENT_USE_WSTRING if (_wstati64(f.c_str(), &ret) < 0) @@ -196,7 +200,20 @@ namespace libtorrent s->atime = ret.st_atime; s->mtime = ret.st_mtime; s->ctime = ret.st_ctime; - s->mode = ret.st_mode; +#if defined TORRENT_WINDOWS + s->mode = ((ret.st_mode & _S_IFREG) ? file_status::regular_file : 0) + | ((ret.st_mode & _S_IFDIR) ? file_status::directory : 0) + | ((ret.st_mode & _S_IFCHR) ? file_status::character_special : 0) + | ((ret.st_mode & _S_IFIFO) ? file_status::fifo : 0); +#else + s->mode = (S_ISREG(ret.st_mode) ? file_status::regular_file : 0) + | (S_ISDIR(ret.st_mode) ? file_status::directory : 0) + | (S_ISLNK(ret.st_mode) ? file_status::link : 0) + | (S_ISFIFO(ret.st_mode) ? file_status::fifo : 0) + | (S_ISCHR(ret.st_mode) ? file_status::character_special : 0) + | (S_ISBLK(ret.st_mode) ? file_status::block_special : 0) + | (S_ISSOCK(ret.st_mode) ? file_status::socket : 0); +#endif } void rename(std::string const& inf, std::string const& newf, error_code& ec) @@ -538,7 +555,7 @@ namespace libtorrent std::string current_working_directory() { -#ifdef TORRENT_WINDOWS +#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW #if TORRENT_USE_WSTRING wchar_t cwd[TORRENT_MAX_PATH]; _wgetcwd(cwd, sizeof(cwd) / sizeof(wchar_t));