Created read method on MString to read from sockets.
This commit is contained in:
parent
cca957b948
commit
7341d26852
@ -6,6 +6,8 @@
|
||||
#include <format>
|
||||
#include <iomanip>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
@ -248,6 +250,13 @@ namespace coreutils {
|
||||
length = size;
|
||||
}
|
||||
|
||||
MString &MString::read(int fd) {
|
||||
char ch;
|
||||
while(::read(fd, &ch, 1))
|
||||
write(ch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int MString::offset() {
|
||||
return cursor - data;
|
||||
}
|
||||
|
@ -214,6 +214,12 @@ namespace coreutils {
|
||||
|
||||
MString &write(ZString &value);
|
||||
|
||||
///
|
||||
/// Read data from a socket and store in MString.
|
||||
///
|
||||
|
||||
MString &read(int fd);
|
||||
|
||||
int offset();
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user