Created read method on MString to read from sockets.

This commit is contained in:
Brad Arant 2024-07-09 12:56:10 -07:00
parent cca957b948
commit 7341d26852
3 changed files with 16 additions and 1 deletions

View File

@ -6,6 +6,8 @@
#include <format>
#include <iomanip>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
namespace coreutils {
@ -247,6 +249,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;

View File

@ -213,6 +213,12 @@ namespace coreutils {
///
MString &write(ZString &value);
///
/// Read data from a socket and store in MString.
///
MString &read(int fd);
int offset();

View File

@ -5,7 +5,7 @@ do
filename="${file%.*}"
list="$list $filename.o"
echo -n "Compiling $filename..."
g++ -g -c $file -std=c++20 &
g++ -g -c $file -std=c++23 &
if [ $? = '0' ]
then
echo "OK"