4 #include <msp/core/systemerror.h>
6 #include "handle_private.h"
11 Handle::operator const void *() const
13 return priv->handle!=-1 ? this : 0;
17 void sys_set_blocking(Handle &handle, bool b)
19 int flags = fcntl(*handle, F_GETFD);
20 fcntl(*handle, F_SETFL, (flags&~O_NONBLOCK)|(b?0:O_NONBLOCK));
23 unsigned sys_read(Handle &handle, char *buf, unsigned size)
25 int ret = read(*handle, buf, size);
31 throw system_error("read");
37 unsigned sys_write(Handle &handle, const char *buf, unsigned size)
39 int ret = write(*handle, buf, size);
45 throw system_error("write");
51 void sys_close(Handle &handle)
56 *handle = INVALID_HANDLE_VALUE;