aboutsummaryrefslogtreecommitdiff
path: root/libbutl/fdstream.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-06-23 14:14:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-06-23 14:14:16 +0200
commitc36042925c8d52e3899ea310018cb7243d191306 (patch)
tree1878230d84e479078862099e06feec807c670041 /libbutl/fdstream.cxx
parent5d50c0499b30650deafc291a3872a386d08a3200 (diff)
Add support for querying position in fdbuf
Diffstat (limited to 'libbutl/fdstream.cxx')
-rw-r--r--libbutl/fdstream.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/libbutl/fdstream.cxx b/libbutl/fdstream.cxx
index 292324a..daa344f 100644
--- a/libbutl/fdstream.cxx
+++ b/libbutl/fdstream.cxx
@@ -145,7 +145,7 @@ namespace butl
setg (buf_, buf_, buf_);
setp (buf_, buf_ + sizeof (buf_) - 1); // Keep space for overflow's char.
-
+ off_ = 0; // @@ Strictly speaking, need to query, can be at end.
fd_ = move (fd);
}
@@ -177,6 +177,8 @@ namespace butl
return -1;
setg (buf_, buf_, buf_ + n);
+ off_ += n;
+
return n;
}
#endif
@@ -223,6 +225,7 @@ namespace butl
throw_ios_failure (errno);
setg (buf_, buf_, buf_ + n);
+ off_ += n;
return n != 0;
}
@@ -295,6 +298,8 @@ namespace butl
if (m == -1)
throw_ios_failure (errno);
+ off_ += m;
+
if (n != static_cast<size_t> (m))
return false;
@@ -352,6 +357,7 @@ namespace butl
throw_ios_failure (errno);
size_t m (static_cast<size_t> (r));
+ off_ += m;
// If the buffered data wasn't fully written then move the unwritten part
// to the beginning of the buffer.
@@ -395,6 +401,7 @@ namespace butl
throw_ios_failure (errno);
size_t m (static_cast<size_t> (r));
+ off_ += m;
// If the buffered data wasn't fully written then move the unwritten part
// to the beginning of the buffer.
@@ -430,6 +437,8 @@ namespace butl
if (r == -1)
throw_ios_failure (errno);
+ off_ += r;
+
return an + r;
#endif
}