X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fpipe.cpp;h=a8487867a137d406699361a3c5d0fe2cfaa35b08;hp=1b275e731667f4736929499aaad7e9a17745343b;hb=6c40658510b68788fd5ef0488b20873b6aa32938;hpb=31e72f50fbb34d86877e5110401c49ce3fefd4bb diff --git a/source/io/pipe.cpp b/source/io/pipe.cpp index 1b275e7..a848786 100644 --- a/source/io/pipe.cpp +++ b/source/io/pipe.cpp @@ -76,14 +76,9 @@ void Pipe::close() set_events(P_NONE); signal_flush_required.emit(); -#ifdef WIN32 - CloseHandle(*handle[0]); - CloseHandle(*handle[1]); -#else - ::close(*handle[0]); - ::close(*handle[1]); + sys_close(handle[0]); + sys_close(handle[1]); signal_closed.emit(); -#endif } void Pipe::set_block(bool b) @@ -105,22 +100,7 @@ unsigned Pipe::do_write(const char *buf, unsigned size) if(size==0) return 0; -#ifdef WIN32 - DWORD ret; - if(!WriteFile(*handle[1], buf, size, &ret, 0)) - throw system_error("WriteFile"); -#else - int ret = ::write(*handle[1], buf, size); - if(ret==-1) - { - if(errno==EAGAIN) - return 0; - else - throw system_error("write"); - } -#endif - - return ret; + return sys_write(handle[1], buf, size); } unsigned Pipe::do_read(char *buf, unsigned size) @@ -153,14 +133,7 @@ unsigned Pipe::do_read(char *buf, unsigned size) // Initiate another overlapped read in case someone is polling us get_event_handle(); #else - int ret = ::read(*handle[0], buf, size); - if(ret==-1) - { - if(errno==EAGAIN) - return 0; - else - throw system_error("read"); - } + unsigned ret = sys_read(handle[0], buf, size); #endif if(ret==0)