More comfort functions: read data into a string object.

This commit is contained in:
Moritz Bunkus 2004-07-31 23:37:12 +00:00
parent b36fbf4fd3
commit e3915fb5da
2 changed files with 18 additions and 0 deletions

View File

@ -361,6 +361,23 @@ mm_io_c::puts_unl(const char *s) {
return bytes_written;
}
uint32_t
mm_io_c::read(string &buffer,
size_t size) {
char cbuffer[size + 1];
int nread;
nread = read(buffer, size);
if (nread < 0)
buffer = "";
else {
cbuffer[nread] = 0;
buffer = cbuffer;
}
return nread;
}
unsigned char
mm_io_c::read_uint8() {
unsigned char value;

View File

@ -45,6 +45,7 @@ public:
virtual void setFilePointer(int64 offset, seek_mode mode = seek_beginning);
virtual bool setFilePointer2(int64 offset, seek_mode mode = seek_beginning);
virtual uint32 read(void *buffer, size_t size);
virtual uint32_t read(string &buffer, size_t size);
virtual unsigned char read_uint8();
virtual uint16_t read_uint16();
virtual uint32_t read_uint24();