From cc3299fb8819e3997bd52d37d39e59e866c5fb75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 19 Dec 2016 16:16:22 +0100 Subject: [PATCH] Fix compilation on Windows and DMD 2.072.1. --- source/eventcore/drivers/posix.d | 3 +++ source/eventcore/drivers/threadedfile.d | 9 +++++++-- source/eventcore/drivers/winapi.d | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/eventcore/drivers/posix.d b/source/eventcore/drivers/posix.d index 71415be..c2e954d 100644 --- a/source/eventcore/drivers/posix.d +++ b/source/eventcore/drivers/posix.d @@ -27,6 +27,9 @@ version (Windows) { import core.sys.windows.winsock2; alias sockaddr_storage = SOCKADDR_STORAGE; alias EAGAIN = WSAEWOULDBLOCK; + enum SHUT_RDWR = SD_BOTH; + enum SHUT_RD = SD_RECEIVE; + enum SHUT_WR = SD_SEND; extern (C) int read(int fd, void *buffer, uint count) nothrow; extern (C) int write(int fd, const(void) *buffer, uint count) nothrow; extern (C) int close(int fd) nothrow @safe; diff --git a/source/eventcore/drivers/threadedfile.d b/source/eventcore/drivers/threadedfile.d index ab70e42..e1b31ed 100644 --- a/source/eventcore/drivers/threadedfile.d +++ b/source/eventcore/drivers/threadedfile.d @@ -147,8 +147,13 @@ final class ThreadedFileEventDriver(Events : EventDriverEvents) : EventDriverFil final override FileFD adopt(int system_file_handle) { - auto flags = () @trusted { return fcntl(system_file_handle, F_GETFD); } (); - if (flags == -1) return FileFD.invalid; + version (Windows) { + // TODO: check if FD is a valid file! + } else { + auto flags = () @trusted { return fcntl(system_file_handle, F_GETFD); } (); + if (flags == -1) return FileFD.invalid; + } + if (m_files[system_file_handle].refCount > 0) return FileFD.invalid; m_files[system_file_handle] = FileInfo.init; m_files[system_file_handle].refCount = 1; diff --git a/source/eventcore/drivers/winapi.d b/source/eventcore/drivers/winapi.d index 3b71698..d9c743d 100644 --- a/source/eventcore/drivers/winapi.d +++ b/source/eventcore/drivers/winapi.d @@ -155,7 +155,7 @@ final class WinAPIEventDriverSockets : EventDriverSockets { assert(false, "TODO!"); } - override void send(DatagramSocketFD socket, const(ubyte)[] buffer, IOMode mode, DatagramIOCallback on_send_finish, Address target_address = null) + override void send(DatagramSocketFD socket, const(ubyte)[] buffer, IOMode mode, Address target_address, DatagramIOCallback on_send_finish) { assert(false, "TODO!"); } @@ -198,7 +198,7 @@ final class WinAPIEventDriverFiles : EventDriverFiles { assert(false, "TODO!"); } - override FileFD createTemp() + override FileFD adopt(int system_handle) { assert(false, "TODO!"); }