From b773d89eba723039d3d293df77e106c128efa878 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 29 Jun 2014 18:14:07 +0200 Subject: [PATCH] BDataIO: Add Flush() --- docs/user/support/DataIO.dox | 20 ++++++++++++++++++-- headers/os/support/DataIO.h | 3 ++- src/kits/support/DataIO.cpp | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/docs/user/support/DataIO.dox b/docs/user/support/DataIO.dox index 7a2f382385..52f2015d07 100644 --- a/docs/user/support/DataIO.dox +++ b/docs/user/support/DataIO.dox @@ -102,8 +102,24 @@ /*! - \fn virtual status_t BDataIO::ReadExactly(void* buffer, size_t size, - size_t* _bytesRead) + \fn virtual status_t BDataIO::Flush() + \brief Writes pending data to underlying storage. + + This method is relevant for BDataIO implementations that buffer data passed + to Write(). The Flush() implementation should make sure that all such data + are written to the underlying storage. + + The default implementation is a no-op returning \c B_OK. + + \return An error code indicating whether flushing the buffered data + succeeded. + + \since Haiku R1 +*/ + + +/*! + \fn virtual status_t BDataIO::ReadExactly(void* buffer, size_t size, size_t* _bytesRead) \brief Reads an exact amount of data from the object into a buffer. This is a convenience wrapper method for Read() for code that expects the diff --git a/headers/os/support/DataIO.h b/headers/os/support/DataIO.h index e39bdcfd66..5e3d9bc99e 100644 --- a/headers/os/support/DataIO.h +++ b/headers/os/support/DataIO.h @@ -17,6 +17,8 @@ public: virtual ssize_t Read(void* buffer, size_t size); virtual ssize_t Write(const void* buffer, size_t size); + virtual status_t Flush(); + status_t ReadExactly(void* buffer, size_t size, size_t* _bytesRead = NULL); status_t WriteExactly(const void* buffer, size_t size, @@ -26,7 +28,6 @@ private: BDataIO(const BDataIO&); BDataIO& operator=(const BDataIO&); - virtual void _ReservedDataIO1(); virtual void _ReservedDataIO2(); virtual void _ReservedDataIO3(); virtual void _ReservedDataIO4(); diff --git a/src/kits/support/DataIO.cpp b/src/kits/support/DataIO.cpp index 90c4b8c676..55e65b40fe 100644 --- a/src/kits/support/DataIO.cpp +++ b/src/kits/support/DataIO.cpp @@ -40,6 +40,13 @@ BDataIO::Write(const void* buffer, size_t size) } +status_t +BDataIO::Flush() +{ + return B_OK; +} + + status_t BDataIO::ReadExactly(void* buffer, size_t size, size_t* _bytesRead) { @@ -116,8 +123,32 @@ BDataIO::operator=(const BDataIO &) } +#if __GNUC__ == 2 + + +extern "C" status_t +_ReservedDataIO1__7BDataIO(BDataIO* self) +{ + return self->BDataIO::Flush(); +} + + +#else + + +// TODO: RELEASE: Remove! + +extern "C" status_t +_ZN7BDataIO16_ReservedDataIO1Ev(BDataIO* self) +{ + return self->BDataIO::Flush(); +} + + +#endif + + // FBC -void BDataIO::_ReservedDataIO1(){} void BDataIO::_ReservedDataIO2(){} void BDataIO::_ReservedDataIO3(){} void BDataIO::_ReservedDataIO4(){}