Add wxInputStream::ReadAll() and wxOutputStream::WriteAll().

Unlike Read() and Write(), these functions always transfer exactly the
specified number of bytes or fail.

See #12056.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74034 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-05-20 13:15:16 +00:00
parent 54582f9ac6
commit cc437b9654
4 changed files with 107 additions and 0 deletions

View File

@@ -128,6 +128,11 @@ public:
// it means that EOF has been reached.
virtual wxInputStream& Read(void *buffer, size_t size);
// Read exactly the given number of bytes, unlike Read(), which may read
// less than the requested amount of data without returning an error, this
// method either reads all the data or returns false.
bool ReadAll(void *buffer, size_t size);
// copy the entire contents of this stream into streamOut, stopping only
// when EOF is reached or an error occurs
wxInputStream& Read(wxOutputStream& streamOut);
@@ -233,6 +238,12 @@ public:
void PutC(char c);
virtual wxOutputStream& Write(const void *buffer, size_t size);
// This is ReadAll() equivalent for Write(): it either writes exactly the
// given number of bytes or returns false, unlike Write() which can write
// less data than requested but still return without error.
bool WriteAll(const void *buffer, size_t size);
wxOutputStream& Write(wxInputStream& stream_in);
virtual wxFileOffset SeekO(wxFileOffset pos, wxSeekMode mode = wxFromStart);