merged mingw fix from RC_0_16

This commit is contained in:
Arvid Norberg 2012-08-21 21:54:07 +00:00
parent 5d993dbc71
commit c60f373ae4
5 changed files with 36 additions and 20 deletions

View File

@ -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

View File

@ -29,7 +29,6 @@ extern "C" {
#include<stdlib.h>
#include<string.h>
#include <sys/types.h> /* for fstat */
#include <sys/stat.h> /* for fstat */
#define SEGMENT_RECORD_LENGTH 3
#define STANDARD_RECORD_LENGTH 3

View File

@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#if defined TORRENT_WINDOWS
#if defined TORRENT_WINDOWS || defined TORRENT_MINGW
#include <malloc.h>
#define TORRENT_ALLOCA(t, n) static_cast<t*>(_alloca(sizeof(t) * (n)))
@ -52,5 +52,3 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#endif

View File

@ -51,8 +51,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/intrusive_ptr_base.hpp"
#include <sys/stat.h>
#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;

View File

@ -43,6 +43,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/scoped_ptr.hpp>
#include <boost/static_assert.hpp>
#include <sys/stat.h>
#ifdef TORRENT_WINDOWS
// windows part
@ -57,16 +59,18 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include <windows.h>
#include <winioctl.h>
#ifndef TORRENT_MINGW
#include <direct.h> // for _getcwd, _mkdir
#else
#include <dirent.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#else
// posix part
#define _FILE_OFFSET_BITS 64
#include <unistd.h>
#include <fcntl.h> // for F_LOG2PHYS
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/statvfs.h>
#include <errno.h>
@ -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));