diff --git a/source/eventcore/drivers/threadedfile.d b/source/eventcore/drivers/threadedfile.d index 9058483..485fd83 100644 --- a/source/eventcore/drivers/threadedfile.d +++ b/source/eventcore/drivers/threadedfile.d @@ -224,6 +224,26 @@ final class ThreadedFileEventDriver(Events : EventDriverEvents) : EventDriverFil return; } on_finish(file, IOStatus.ok, 0); + } else version (Windows) { + import core.sys.windows.windows : FILE_BEGIN, HANDLE, INVALID_HANDLE_VALUE, + LARGE_INTEGER, SetFilePointerEx, SetEndOfFile; + import core.stdc.stdio : _get_osfhandle; + + auto h = () @trusted { return cast(HANDLE)_get_osfhandle(cast(int)file); } (); + if (h == INVALID_HANDLE_VALUE) { + on_finish(file, IOStatus.error, 0); + return; + } + LARGE_INTEGER ls = { QuadPart: size }; + if (!() @trusted { return SetFilePointerEx(h, ls, null, FILE_BEGIN); } ()) { + on_finish(file, IOStatus.error, 0); + return; + } + if (!() @trusted { return SetEndOfFile(h); } ()) { + on_finish(file, IOStatus.error, 0); + return; + } + on_finish(file, IOStatus.ok, 0); } else { on_finish(file, IOStatus.error, 0); } @@ -379,7 +399,7 @@ log("trigger event"); if (bytes.length == 0) safeAtomicStore(f.ioStatus, IOStatus.ok); while (bytes.length > 0) { - auto sz = min(bytes.length, 4096); + auto sz = min(bytes.length, 512*1024); auto ret = () @trusted { return mixin("."~op)(cast(int)file, bytes.ptr, cast(uint)sz); } (); if (ret != sz) { safeAtomicStore(f.ioStatus, IOStatus.error);