summaryrefslogtreecommitdiff
path: root/src/io/write_test.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-02-04 23:18:54 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-02-06 11:18:37 -0800
commit9215c35975be745628e8188473154c7e476add55 (patch)
tree14d4f5d51381f8a59803233c24dfafc846ddf583 /src/io/write_test.cpp
parent9544985ccbb20d7f8377c63a4e59d1ff97b844ac (diff)
downloadtmwa-9215c35975be745628e8188473154c7e476add55.tar.gz
tmwa-9215c35975be745628e8188473154c7e476add55.tar.bz2
tmwa-9215c35975be745628e8188473154c7e476add55.tar.xz
tmwa-9215c35975be745628e8188473154c7e476add55.zip
Wrap remaining FDs in a class
Diffstat (limited to 'src/io/write_test.cpp')
-rw-r--r--src/io/write_test.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/io/write_test.cpp b/src/io/write_test.cpp
index 36ffe88..a9736b8 100644
--- a/src/io/write_test.cpp
+++ b/src/io/write_test.cpp
@@ -10,22 +10,21 @@
#include "../strings/xstring.hpp"
static
-int pipew(int& rfd)
+io::FD pipew(io::FD& rfd)
{
- int pfd[2];
- if (-1 == pipe2(pfd, O_NONBLOCK))
+ io::FD wfd;
+ if (-1 == io::FD::pipe2(rfd, wfd, O_NONBLOCK))
{
- rfd = -1;
- return -1;
+ rfd = io::FD();
+ return io::FD();
}
- rfd = pfd[0];
- return pfd[1];
+ return wfd;
}
class PipeWriter
{
private:
- int rfd;
+ io::FD rfd;
public:
io::WriteFile wf;
public:
@@ -34,7 +33,7 @@ public:
{}
~PipeWriter()
{
- close(rfd);
+ rfd.close();
}
FString slurp()
{
@@ -42,7 +41,7 @@ public:
char buf[4096];
while (true)
{
- ssize_t rv = read(rfd, buf, sizeof(buf));
+ ssize_t rv = rfd.read(buf, sizeof(buf));
if (rv == -1)
{
if (errno != EAGAIN)