3 #include <msp/core/systemerror.h>
5 #include "handle_private.h"
14 Handle::Handle(const Handle &other):
17 priv->handle = other.priv->handle;
20 Handle &Handle::operator=(const Handle &other)
22 priv->handle = other.priv->handle;
31 Handle::operator const void *() const
34 return priv->handle!=INVALID_HANDLE_VALUE ? this : 0;
36 return priv->handle!=-1 ? this : 0;
41 Handle::Private::Private():
43 handle(INVALID_HANDLE_VALUE)
49 Handle::Private &Handle::Private::operator=(H h)
56 unsigned sys_read(Handle &handle, char *buf, unsigned size)
60 if(ReadFile(*handle, buf, size, &ret, 0)==0)
61 throw system_error("ReadFile");
63 int ret = read(*handle, buf, size);
69 throw system_error("read");
76 unsigned sys_write(Handle &handle, const char *buf, unsigned size)
80 if(WriteFile(*handle, buf, size, &ret, 0)==0)
81 throw system_error("WriteFile");
83 int ret = write(*handle, buf, size);
89 throw system_error("write");
96 void sys_close(Handle &handle)