X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fwindows%2Fhandle.cpp;h=6d1219a24859e7757e9b1ba9e114ffbffa3793d7;hp=17aabb080bb113c3e8e35a59f5cb7ae2f5fdafef;hb=41363aed34382386f915f17c1a961750b4fdcb14;hpb=8e696b9c1ee35f2ce5b9264f31b1963758d65ced diff --git a/source/io/windows/handle.cpp b/source/io/windows/handle.cpp index 17aabb0..6d1219a 100644 --- a/source/io/windows/handle.cpp +++ b/source/io/windows/handle.cpp @@ -1,33 +1,41 @@ +#define NOMINMAX +#include #include #include "handle.h" #include "handle_private.h" +using namespace std; + namespace Msp { namespace IO { -Handle::operator const void *() const +void sys_set_blocking(Handle &, bool) { - return priv->handle!=INVALID_HANDLE_VALUE ? this : 0; } - -void sys_set_blocking(Handle &, bool) +void sys_set_inherit(Handle &, bool) { } -unsigned sys_read(Handle &handle, char *buf, unsigned size) +size_t sys_read(Handle &handle, char *buf, size_t size) { + if(size>numeric_limits::max()) + throw invalid_argument("read"); + DWORD ret; - if(ReadFile(*handle, buf, size, &ret, 0)==0) + if(ReadFile(*handle, buf, size, &ret, nullptr)==0) throw system_error("ReadFile"); return ret; } -unsigned sys_write(Handle &handle, const char *buf, unsigned size) +size_t sys_write(Handle &handle, const char *buf, size_t size) { + if(size>numeric_limits::max()) + throw invalid_argument("write"); + DWORD ret; - if(WriteFile(*handle, buf, size, &ret, 0)==0) + if(WriteFile(*handle, buf, size, &ret, nullptr)==0) throw system_error("WriteFile"); return ret;