X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fwindows%2Fhandle.cpp;fp=source%2Fio%2Fwindows%2Fhandle.cpp;h=5b1d93368f3386adeab823b1c67c121a1cbd3264;hp=0000000000000000000000000000000000000000;hb=609c9a508cfdc7b42c46c4f21d17639204165a00;hpb=b4806214e905752617691f851717033fd3f266c2 diff --git a/source/io/windows/handle.cpp b/source/io/windows/handle.cpp new file mode 100644 index 0000000..5b1d933 --- /dev/null +++ b/source/io/windows/handle.cpp @@ -0,0 +1,42 @@ +#include +#include "handle.h" +#include "handle_private.h" + +namespace Msp { +namespace IO { + +Handle::operator const void *() const +{ + return priv->handle!=INVALID_HANDLE_VALUE ? this : 0; +} + + +void sys_set_blocking(Handle &, bool) +{ +} + +unsigned sys_read(Handle &handle, char *buf, unsigned size) +{ + DWORD ret; + if(ReadFile(*handle, buf, size, &ret, 0)==0) + throw system_error("ReadFile"); + + return ret; +} + +unsigned sys_write(Handle &handle, const char *buf, unsigned size) +{ + DWORD ret; + if(WriteFile(*handle, buf, size, &ret, 0)==0) + throw system_error("WriteFile"); + + return ret; +} + +void sys_close(Handle &handle) +{ + CloseHandle(*handle); +} + +} // namespace IO +} // namespace Msp