]> git.tdb.fi Git - libs/core.git/blob - source/io/windows/handle.cpp
Move Handle::operator void * to the common part
[libs/core.git] / source / io / windows / handle.cpp
1 #include <msp/core/systemerror.h>
2 #include "handle.h"
3 #include "handle_private.h"
4
5 namespace Msp {
6 namespace IO {
7
8 void sys_set_blocking(Handle &, bool)
9 {
10 }
11
12 unsigned sys_read(Handle &handle, char *buf, unsigned size)
13 {
14         DWORD ret;
15         if(ReadFile(*handle, buf, size, &ret, 0)==0)
16                 throw system_error("ReadFile");
17
18         return ret;
19 }
20
21 unsigned sys_write(Handle &handle, const char *buf, unsigned size)
22 {
23         DWORD ret;
24         if(WriteFile(*handle, buf, size, &ret, 0)==0)
25                 throw system_error("WriteFile");
26
27         return ret;
28 }
29
30 void sys_close(Handle &handle)
31 {
32         if(handle)
33         {
34                 CloseHandle(*handle);
35                 *handle = INVALID_HANDLE_VALUE;
36         }
37 }
38
39 } // namespace IO
40 } // namespace Msp